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


C# DefaultKernel.AddChildKernel方法代码示例

本文整理汇总了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
 }
开发者ID:AGiorgetti,项目名称:Castle.InversionOfControl,代码行数:8,代码来源:IoC-95.cs

示例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
		}
开发者ID:castleproject,项目名称:Windsor,代码行数:8,代码来源:IoC-95.cs

示例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)];
		}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:12,代码来源:SubContainersTestCase.cs

示例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)];
		}
开发者ID:gschuager,项目名称:Castle.Windsor,代码行数:12,代码来源:SubContainersTestCase.cs

示例5: AddChildKernelToTwoParentsThrowsException

		public void AddChildKernelToTwoParentsThrowsException()
		{
			IKernel kernel2 = new DefaultKernel();

			IKernel subkernel = new DefaultKernel();

			kernel.AddChildKernel(subkernel);
			Assert.AreEqual(kernel, subkernel.Parent);

			kernel2.AddChildKernel(subkernel);
		}
开发者ID:n2cms,项目名称:Castle.Windsor,代码行数:11,代码来源:SubContainersTestCase.cs

示例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>();
		}
开发者ID:n2cms,项目名称:Castle.Windsor,代码行数:19,代码来源:SubContainersTestCase.cs

示例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>();
		}
开发者ID:n2cms,项目名称:Castle.Windsor,代码行数:13,代码来源:SubContainersTestCase.cs


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