Exemple #1
0
        public static IUnityContainer BuildUnityContainer()
        {
            Microsoft.Practices.Unity.UnityContainer container = new Microsoft.Practices.Unity.UnityContainer();

            container.RegisterType <ITestService, TestService>();
            container.RegisterType <IUserService, UserService>();
            container.RegisterType <IRoleService, RoleService>();
            container.RegisterType <ITestResultService, TestResultService>();
            container.RegisterType <IAnswerService, AnswerService>();
            container.RegisterType <IQuestionService, QuestionService>();

            UnityBllConfig.BuildUnityBllContainer(container);

            return(container);
        }
        /// <summary>Registers the type mappings with the Unity container.</summary>
        /// <param name="container">The unity container to configure.</param>
        /// <remarks>There is no need to register concrete types such as controllers or API controllers (unless you want to
        /// change the defaults), as Unity allows resolving a concrete type even if it was not previously registered.</remarks>
        public static void RegisterTypes(IUnityContainer container)
        {
            // NOTE: To load from web.config uncomment the line below. Make sure to add a Microsoft.Practices.Unity.Configuration to the using statements.
            // container.LoadConfiguration();

            // TODO: Register your types here
            // container.RegisterType<IProductRepository, ProductRepository>();
            container.RegisterType <ITestService, TestService>(new PerResolveLifetimeManager());
            container.RegisterType <IUserService, UserService>(new PerResolveLifetimeManager());
            container.RegisterType <IRoleService, RoleService>(new PerResolveLifetimeManager());
            container.RegisterType <ITestResultService, TestResultService>(new PerResolveLifetimeManager());
            container.RegisterType <IAnswerService, AnswerService>(new PerResolveLifetimeManager());
            container.RegisterType <IQuestionService, QuestionService>(new PerResolveLifetimeManager());
            container.RegisterType <CustomMembershipProvider, CustomMembershipProvider>();
            container.RegisterType <CustomRoleProvider, CustomRoleProvider>();

            UnityBllConfig.BuildUnityBllContainer(container);
        }