当前位置: 首页>>代码示例>>C#>>正文


C# IWindsorContainer.AddChildContainer方法代码示例

本文整理汇总了C#中IWindsorContainer.AddChildContainer方法的典型用法代码示例。如果您正苦于以下问题:C# IWindsorContainer.AddChildContainer方法的具体用法?C# IWindsorContainer.AddChildContainer怎么用?C# IWindsorContainer.AddChildContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IWindsorContainer的用法示例。


在下文中一共展示了IWindsorContainer.AddChildContainer方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateChildContainer

 private static IWindsorContainer CreateChildContainer(IWindsorContainer parent)
 {
     var sessionComponent =
         Component.For<IDocumentSession>()
                  .UsingFactoryMethod(
                      kernel => kernel.Resolve<IDocumentStore>().OpenSession())
                  .LifestyleTransient();
     var container = new WindsorContainer();
     container.Register(sessionComponent);
     parent.AddChildContainer(container);
     return container;
 }
开发者ID:dlidstrom,项目名称:EventStoreLite,代码行数:12,代码来源:Program.cs

示例2: CreateChildContainer

 private static IWindsorContainer CreateChildContainer(IWindsorContainer container)
 {
     var childContainer = new WindsorContainer();
     childContainer.Register(
         Component.For<IDocumentSession>()
                  .UsingFactoryMethod(kernel =>
                  {
                      var documentSession = kernel.Resolve<IDocumentStore>().OpenSession();
                      documentSession.Advanced.UseOptimisticConcurrency = true;
                      return documentSession;
                  })
                  .LifestyleTransient());
     container.AddChildContainer(childContainer);
     return childContainer;
 }
开发者ID:dlidstrom,项目名称:EventStoreLite,代码行数:15,代码来源:Global.asax.cs

示例3: BuildTenants

        TenantManager BuildTenants(IWindsorContainer container, DocumentStoreConfiguration config)
        {
            _logger.Debug("Configuring tenants");
            var manager = new TenantManager(container.Kernel);
            container.Register(Component.For<ITenantAccessor, TenantManager>().Instance(manager));

            foreach (var settings in config.TenantSettings)
            {
                _logger.DebugFormat("Adding tenant {0}", settings.TenantId);

                var tenant = manager.AddTenant(settings);
                tenant.Container.Kernel.Resolver.AddSubResolver(new CollectionResolver(tenant.Container.Kernel, true));
                tenant.Container.Kernel.Resolver.AddSubResolver(new ArrayResolver(tenant.Container.Kernel, true));
                tenant.Container.AddFacility<StartableFacility>();

                container.AddChildContainer(tenant.Container);
            }

            return manager;
        }
开发者ID:ProximoSrl,项目名称:Jarvis.DocumentStore,代码行数:20,代码来源:DocumentStoreBootstrapper.cs

示例4: Install

        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            var childContainer = new WindsorContainer();
            childContainer.Kernel.Resolver.AddSubResolver(new EnvironmentResolver());
            childContainer.Kernel.Resolver.AddSubResolver(
                new ArrayResolver(childContainer.Kernel, true));
            childContainer.Kernel.AddHandlersFilter(new RestHandlerFilter());
            childContainer.Kernel.AddHandlersFilter(new BatchHandlerFilter());
            childContainer.Kernel.AddHandlersFilter(new CacheHandlerFilter());
            childContainer.Kernel.AddHandlersFilter(new ContravariantFilter());
            childContainer.Kernel.AddHandlerSelector(new PipelineSelector());

            childContainer.Register(
                Component.For<IMediator>().ImplementedBy<ScopedMediator>(),
                Component.For<EnvironmentInterceptor>().LifestyleTransient()
            );

            foreach (var assembly in _fromAssemblies
                .Concat(new[] {Classes.FromThisAssembly()}))
            {
                childContainer.Register(assembly
                    .BasedOn(typeof (IRequestHandler<,>))
                    .OrBasedOn(typeof (IRequestMiddleware<,>))
                    .OrBasedOn(typeof (IAsyncRequestHandler<,>))
                    .OrBasedOn(typeof (INotificationHandler<>))
                    .OrBasedOn(typeof (IAsyncNotificationHandler<>))
                    .OrBasedOn(typeof (IValidator<>))
                    .WithServiceBase()
                    .LifestyleScoped()
                    .Configure(c =>
                    {
                        c.Proxy.Hook(new EnvironmentProxyGenerationHook())
                             .Interceptors<EnvironmentInterceptor>();
                        if (c.Implementation != null)
                        {
                            var requiresMatching = c.Implementation.GetInterface(
                                typeof (IRequireGenericMatching<>).FullName);
                            if (requiresMatching == null) return;
                            var matcher = requiresMatching.GetGenericArguments()[0];
                            c.ExtendedProperties(
                                Property.ForKey(Constants.GenericImplementationMatchingStrategy)
                                    .Eq(Activator.CreateInstance(matcher)));
                        }
                    }));
            }

            container.Register(Component.For<IValidatorFactory>()
                     .ImplementedBy<WindsorValidatorFactory>()
                     .OnlyNewServices());

            container.AddChildContainer(childContainer);
            container.Register(Component.For<IMediator>()
                     .Instance(childContainer.Resolve<IMediator>()));
        }
开发者ID:provenstyle,项目名称:Presentations-UltraModernWebDevelopment,代码行数:54,代码来源:MediatRInstaller.cs


注:本文中的IWindsorContainer.AddChildContainer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。