January 20, 2017 2 Comments
In the previous post we looked at how dependencies and dependency injection work in .NET Core. New libraries can be downloaded to the solution in various ways: through the NuGet GUI, The NuGet package manager console, by editing project.json directly or letting Visual Studio figure out if a certain library could solve a missing reference problem. Dependency injection can be achieved through a built-in IoC – Inversion of Control container – where we register the abstractions and the corresponding dependencies in Startup.cs. We can give various lifetimes to the dependencies: transient, scoped and singleton. Then whenever a class requires a dependency the IoC container will serve up the registered concrete implementation automatically.
In this post we’ll see how to add a configuration file to the project and how to read from it.