本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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>()));
}