Пример #1
0
        private static void InitializeIocAndFramework()
        {
            //初始化IoC
            IUnityContainer container = new UnityContainer();

            container.RegisterType <IObjectEventMapping, DomainLayerObjectEventMapping>(new ContainerControlledLifetimeManager());
            container.RegisterType <IUnitOfWork, UnitOfWork>(new ContainerControlledLifetimeManager());

            //将IoC保存到静态变量中,以便永久保存该对象
            UnityContainerHolder.UnityContainer = container;

            //为框架提供一个InstanceLocator
            InstanceLocator.SetLocator(new ExampleInstanceLocator());

            container.RegisterInstance(typeof(BankAccountCollection), new BankAccountCollection());
            container.RegisterInstance(typeof(CustomerCollection), new CustomerCollection());
            container.RegisterInstance(typeof(ForumUserCollection), new ForumUserCollection());
            container.RegisterInstance(typeof(ReplyCollection), new ReplyCollection());
            container.RegisterInstance(typeof(TopicCollection), new TopicCollection());

            //将所有Event和EventHandler建立映射关系
            var eventSubscriberTypeMappingStore = EventSubscriberTypeMappingStore.Current;

            eventSubscriberTypeMappingStore.ResolveEventSubscriberTypeMappings(typeof(BankAccount).Assembly);
            eventSubscriberTypeMappingStore.ResolveEventSubscriberTypeMappings(typeof(BankAccountCollection).Assembly);
        }
Пример #2
0
        public void Run()
        {
            var             path      = ConfigurationManager.AppSettings["ContainerConfigPath"];
            IUnityContainer container = UnityContainerHelper.Create(path);

            InstanceLocator.SetLocator(new MyInstanceLocator(container));
        }
Пример #3
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            AuthConfig.RegisterAuth();

            InstanceLocator.SetLocator(
                new NinjectContainer().WireDependenciesInAssemblies(typeof(ItemCatsApi).Assembly.FullName).Locator);
        }
Пример #4
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            RegisterRoutes(RouteTable.Routes);

            ControllerBuilder.Current.SetControllerFactory(typeof(CommonServiceLocatorControllerFactory));

            IUnityContainer container = new UnityContainer();

            ((UnityConfigurationSection)ConfigurationManager.GetSection("unity")).Configure(container);
            UnityContainerHolder.UnityContainer = container;
            InstanceLocator.SetLocator(new ForumInstanceLocator());

            var eventSubscriberTypeMappingStore = EventSubscriberTypeMappingStore.Current;

            eventSubscriberTypeMappingStore.ResolveEventSubscriberTypeMappings(typeof(Group).Assembly);
            eventSubscriberTypeMappingStore.ResolveEventSubscriberTypeMappings(typeof(GroupCollection).Assembly);
        }
Пример #5
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            Logger.InitLogger();

            //Logger.LogMsg(LogLevel.Error, "test");
            //Logger.Log.Debug("测试正在启动:Debug");
            //Logger.Log.Error("测试正在启动:Error");
            //Logger.Log.Fatal("测试正在启动:Fatal");
            //Logger.Log.Info("测试正在启动:Info");
            //Logger.Log.Warn("测试正在启动:Warn");

            InstanceLocator.SetLocator(
                new NinjectContainer().WireDependenciesInAssemblies(typeof(AppModule).Assembly.FullName).Locator);
        }
Пример #6
0
 static UserServiceTest()
 {
     InstanceLocator.SetLocator(
         new NinjectContainer().WireDependenciesInAssemblies(typeof(AppModule).Assembly.FullName).Locator);
 }
Пример #7
0
 static SysRoleRepositoryTest()
 {
     InstanceLocator.SetLocator(
         new NinjectContainer().WireDependenciesInAssemblies(typeof(AppModule).Assembly.FullName).Locator);
 }
Пример #8
0
 private static void StartUp()
 {
     InstanceLocator.SetLocator(
         new NinjectContainer().WireDependenciesInAssemblies(typeof(ItemCatsApi).Assembly.FullName).Locator);
 }
Пример #9
0
 public void Initialize()
 {
     InstanceLocator.SetLocator(
         new NinjectContainer().WireDependenciesInAssemblies(typeof(ItemCatsApi).Assembly.FullName).Locator);
 }