„Get out form smog” – dependency injection

dsp2017

Get out from smog – part V

Today post will be about depencendy injection.And run all the written functions as a whole. Uses for this Autofac and Autofac.Mvc – to inject depencencies on the contollers.

I created class to register depencencies.

We register the interface to a particular class and the ability to inject into the contoller.

Now inject interface into the contoller constructor.

Thanks to this magician we can now call our functions like this:

Thanks to this, we have received the nears measuring station within a radius of 100 km from the user’s location.

getoutfromsmog

In the next step I will try to find the cleanest air among from this stactions.

Link to the project: HERE

Dodaj komentarz

Twój adres email nie zostanie opublikowany. Pola, których wypełnienie jest wymagane, są oznaczone symbolem *