Click here to Skip to main content
15,867,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am implementing dependency injection in my project using unity. And to register type i have created another project (LibraryManagement.DIMapping) which has registsered type for all layers(Business, Data) and added its reference in presentation layer. Issue am facing here is how to configure unity container in global.asax. so that container will be avaliable in all different layers. Do i need to d any setting in web.config file since i have already registered mapping in cs file? Here is the screenshot of DIRegister class<pre></pre>

XML
public IUnityContainer InitializeMapping()
        {
            IUnityContainer container = new UnityContainer();
            //Business Layer
            container.RegisterType<ICourseManager, CourseManager>();
            container.RegisterType<IEnrollmentManager, EnrollmentManager>();
            container.RegisterType<IStateManager, StateManager>();
            container.RegisterType<IStudentManager, StudentManager>();

            //Data layer
            container.RegisterType<IStudentRepository, StudentRepository>();
            container.RegisterType(typeof(IRepository<>), typeof(Repository<>));
            container.RegisterType<ICourseRepository, CourseRepository>();
            container.RegisterType<IEnrollmentRepository, EnrollmentRepository>();

            return container;
        }
Posted
Updated 26-Feb-14 23:38pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900