I have a 3-level NIT service app, which adheres to the standard approach:
Frontend - & gt; Object Model / Business Logic - & gt; Data Access
I am trying to know about dependence injection on the way, and so far it has got very good (using AutoFac). Each 3 levels need to be classified as an object, sometimes with additional configuration / etc. It seems that the DI container should be the ideal thing to solve it, but I am facing some problems where it should remain with regard to the rest of the system.
At this time I have a square, the front end configuring the DIA container is basically a huge set of container code. Registrar & lt; SomeType & gt; ()
and so on.
The problem is, it is configuring the container for all 3 levels, and therefore there should be quite aggressive knowledge of the data access layer. Keeping the code in my frontend with this kind of knowledge closes the alarm bell in my head because the app is being applied to different places to avoid this precise situation.
It is also worse than the fact that my data is not an access layer, just a dumb bucket of SQL server bits, but very complicated COM interop and P / call are included, so there is a great effect on D configuration .
I have given some thought to break it up - maybe there is a container at each level, or there is going to be a "setup" class in each level that talks to the global di container Register bits, but I'm not sure that more problems will be resolved.
I appreciate that anyone can share their experience with using multitied apps in the di.
Thanks, Orion.
It depends on you if you have three levels (physical separation) or if all your logical Layers are deployed together if the frontend is different from your BL and communicates via a webservice or WCF, then the frontend and backend need their containers because they are running in different processes or in different machines. Containers only register their own components and interface of the 'next' layer.
On the other hand if all the layers are in the same process then you should have only one container. Containers will be started and hosted for the web app at the starting point of the application like global.asax.
The problem with the container host can not be found to register the classes individually, to know all the different parts of the system, but to enter all types of names in a single assembly. In this way you do not need strong references to all the assemblies in your solution to configure the container. Example of how this can be done with Castle Windsor:
Kernel Registrar (All Types. Pick). FromAssemblyName ("DataAccessLayer.dll")); Kernel.Register (AllTypes.Pick) FromAssemblyName ("BusinessLogic.dll").);
Comments
Post a Comment