I have a VS2015 solution in which I have a ASP.NET5 WebAPI project and three class libraries (.csProj).
Class Library 1 has reference to Class library 2 and Class library 3.
In class Library 2 I have classes that has business logic written and it access an outside service to get the data as well.
In class library 3 I have classes that has business logic written and it access my own Dbse to get the data.
Class library 1 has references to class library 2 and 3 and it has classes that eventually calls the classes of class library-2 and 3 internally. Class Lbrary 1 actually provides a facade to use by WebAPI so WebAPI is agnostic of place from where data comes.
And In WebAPI I have reference to Class library 1.
Now I need to use Dependency Injection but I do not know how to do this. All the examples that I have seen on net (and in dos.asp.net, and other places) they only talk about the Model classes and provide their references in Controller, moreover the model classes they have taken in example do not have constructors that accepts parameter.
My dilemma is that how can I use the DI in the above stated scenario, I need to have DI in the class libraries that I need to access in WebAPI. As it is DI and class libraries are to be accessed in WebAPI so DI's starting point should be from WebAPI, but I do not understand how can I do that and the classes that I have in my class libraries has Parametrized constructor.
e.g. In class library 2 I have an Interface and it's implementation class that has parametrized constructor. The Parameteised constructor takes a string parameter, which is used later in the functions to get the value from configuration file. In class lib1 I have reference to Class lib 2. In WebAPI I have reference to Class Lib 1. So now how I can use DI to initialize all these classes in Class Lib1 and Class lib 2 ? (UsedMicrosoft.Practices.Unity, and it is not working) So is there a way that I use ASP.NET 5's in-built DI to initialize the classes of class library 1 and class library 2?
Please help me out.. I am scratching my head and pulling my hairs out just to get this working!!!