本文整理汇总了C#中DefaultKernel.AddChildKernel方法的典型用法代码示例。如果您正苦于以下问题:C# DefaultKernel.AddChildKernel方法的具体用法?C# DefaultKernel.AddChildKernel怎么用?C# DefaultKernel.AddChildKernel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DefaultKernel
的用法示例。
在下文中一共展示了DefaultKernel.AddChildKernel方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddingComponentToRootKernelWhenChildKernelHasStartableFacility
public void AddingComponentToRootKernelWhenChildKernelHasStartableFacility()
{
IKernel kernel = new DefaultKernel();
IKernel childKernel = new DefaultKernel();
kernel.AddChildKernel(childKernel);
childKernel.AddFacility("StartableFacility", new StartableFacility());
kernel.AddComponent("string", typeof(String)); // exception here
}
示例2: AddingComponentToRootKernelWhenChildKernelHasStartableFacility
public void AddingComponentToRootKernelWhenChildKernelHasStartableFacility()
{
IKernel kernel = new DefaultKernel();
IKernel childKernel = new DefaultKernel();
kernel.AddChildKernel(childKernel);
childKernel.AddFacility(new StartableFacility());
kernel.Register(Component.For(typeof (A)).Named("string")); // exception here
}
示例3: ChildDependenciesIsSatisfiedEvenWhenComponentTakesLongToBeAddedToParentContainer
public void ChildDependenciesIsSatisfiedEvenWhenComponentTakesLongToBeAddedToParentContainer()
{
DefaultKernel container = new DefaultKernel();
DefaultKernel childContainer = new DefaultKernel();
container.AddChildKernel(childContainer);
childContainer.AddComponent("component", typeof(Component));
container.AddComponent("service1", typeof(IService), typeof(Service));
Component comp = (Component) childContainer[typeof(Component)];
}
示例4: ChildDependenciesIsSatisfiedEvenWhenComponentTakesLongToBeAddedToParentContainer
public void ChildDependenciesIsSatisfiedEvenWhenComponentTakesLongToBeAddedToParentContainer()
{
DefaultKernel container = new DefaultKernel();
DefaultKernel childContainer = new DefaultKernel();
container.AddChildKernel(childContainer);
((IKernel)childContainer).Register(Component.For(typeof(UsesIEmptyService)).Named("component"));
((IKernel)container).Register(Component.For(typeof(IEmptyService)).ImplementedBy(typeof(EmptyService)).Named("service1"));
UsesIEmptyService comp = (UsesIEmptyService) childContainer[typeof(UsesIEmptyService)];
}
示例5: AddChildKernelToTwoParentsThrowsException
public void AddChildKernelToTwoParentsThrowsException()
{
IKernel kernel2 = new DefaultKernel();
IKernel subkernel = new DefaultKernel();
kernel.AddChildKernel(subkernel);
Assert.AreEqual(kernel, subkernel.Parent);
kernel2.AddChildKernel(subkernel);
}
示例6: Three_level_hierarchy
public void Three_level_hierarchy([Values(0, 1, 2)] int parentComponentContainer,
[Values(0, 1, 2)] int childComponentContainer)
{
var subKernel = new DefaultKernel();
var subSubKernel = new DefaultKernel();
kernel.AddChildKernel(subKernel);
subKernel.AddChildKernel(subSubKernel);
var containers = new[]
{
kernel,
subKernel,
subSubKernel
};
containers[parentComponentContainer].Register(Component.For<UsesSimpleComponent1>());
containers[childComponentContainer].Register(Component.For<SimpleComponent1>());
subSubKernel.Resolve<UsesSimpleComponent1>();
}
示例7: ChildDependenciesIsSatisfiedEvenWhenComponentTakesLongToBeAddedToParentContainer
public void ChildDependenciesIsSatisfiedEvenWhenComponentTakesLongToBeAddedToParentContainer()
{
var container = new DefaultKernel();
var childContainer = new DefaultKernel();
container.AddChildKernel(childContainer);
childContainer.Register(Component.For(typeof(UsesIEmptyService)).Named("component"));
container.Register(
Component.For(typeof(IEmptyService)).ImplementedBy(typeof(EmptyServiceA)).Named("service1"));
var comp = childContainer.Resolve<UsesIEmptyService>();
}