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


C# WindsorContainer.AddChildContainer方法代码示例

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


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

示例1: AddingToTwoParentContainsThrowsKernelException

		public void AddingToTwoParentContainsThrowsKernelException()
		{
			IWindsorContainer container3 = new WindsorContainer();
			IWindsorContainer childcontainer = new WindsorContainer();
			Container.AddChildContainer(childcontainer);
			container3.AddChildContainer(childcontainer);
		}
开发者ID:RookieX,项目名称:Windsor,代码行数:7,代码来源:ChildContainerSupportTestCase.cs

示例2: ShouldResolveComponentFromParent

 public void ShouldResolveComponentFromParent()
 {
     WindsorContainer parent = new WindsorContainer();
     WindsorContainer child = new WindsorContainer();
     parent.AddChildContainer(child);
     parent.AddComponent("DoNothingService", typeof(IDoNothingService), typeof(DoNothingService));
     child.AddComponent("DoSomethingService", typeof(IDoSomethingService), typeof(DoSomethingService));
     Assert.IsNotNull(child.Resolve<IDoNothingService>());
     Assert.IsNotNull(child.Resolve<IDoSomethingService>());
 }
开发者ID:AGiorgetti,项目名称:Castle.InversionOfControl,代码行数:10,代码来源:ConfigureDecoratorsTestCase.cs

示例3: ShouldResolveComponentFromParent

 public void ShouldResolveComponentFromParent()
 {
     WindsorContainer parent = new WindsorContainer();
     WindsorContainer child = new WindsorContainer();
     parent.AddChildContainer(child);
     ((IWindsorContainer)parent).Register(Component.For(typeof(IDoNothingService)).ImplementedBy(typeof(DoNothingService)).Named("DoNothingService"));
     ((IWindsorContainer)child).Register(Component.For(typeof(IDoSomethingService)).ImplementedBy(typeof(DoSomethingService)).Named("DoSomethingService"));
     Assert.IsNotNull(child.Resolve<IDoNothingService>());
     Assert.IsNotNull(child.Resolve<IDoSomethingService>());
 }
开发者ID:gschuager,项目名称:Castle.Windsor,代码行数:10,代码来源:ConfigureDecoratorsTestCase.cs

示例4: ShouldResolveComponentFromParent

		public void ShouldResolveComponentFromParent()
		{
			var parent = new WindsorContainer();
			var child = new WindsorContainer();
			parent.AddChildContainer(child);
			parent.Register(
				Component.For<IDoNothingService>().ImplementedBy<DoNothingService>().Named("DoNothingService"),
				Component.For<IDoSomethingService>().ImplementedBy<DoSomethingService>().Named("DoSomethingService"));

			Assert.IsNotNull(child.Resolve<IDoNothingService>());
			Assert.IsNotNull(child.Resolve<IDoSomethingService>());
		}
开发者ID:vbedegi,项目名称:Castle.InversionOfControl,代码行数:12,代码来源:ConfigureDecoratorsTestCase.cs

示例5: ShouldResolveDecoratedComponentFromParent

 public void ShouldResolveDecoratedComponentFromParent()
 {
     WindsorContainer parent = new WindsorContainer();
     WindsorContainer child = new WindsorContainer();
     parent.AddChildContainer(child);
     parent.AddComponent("DoNothingServiceDecorator", typeof(IDoNothingService), typeof(DoNothingServiceDecorator));
     parent.AddComponent("DoNothingService", typeof(IDoNothingService), typeof(DoNothingService));
     child.AddComponent("DoSometingService", typeof(IDoSomethingService), typeof(DoSomethingService));
     IDoNothingService service = child.Resolve<IDoNothingService>();
     Assert.IsNotNull(service);
     Assert.IsInstanceOf(typeof(DoNothingServiceDecorator), service);
 }
开发者ID:AGiorgetti,项目名称:Castle.InversionOfControl,代码行数:12,代码来源:ConfigureDecoratorsTestCase.cs

示例6: Cannot_resolve_a_dependency_from_a_parent_container_under_certain_circumstances

		public void Cannot_resolve_a_dependency_from_a_parent_container_under_certain_circumstances()
		{
			var parent = new WindsorContainer();
			var child = new WindsorContainer();

			parent.AddChildContainer(child);

			((IWindsorContainer)parent).Register(Component.For(typeof(IParentService)).ImplementedBy(typeof(ParentService)).Named("service"));
			((IWindsorContainer)child).Register(Component.For(typeof(IChildService1)).ImplementedBy(typeof(ChildService1)).Named("service1"));
			((IWindsorContainer)child).Register(Component.For(typeof(IChildService2)).ImplementedBy(typeof(ChildService2)).Named("service2"));

			child.Resolve<IChildService1>();
		}
开发者ID:rtr0mdrn,项目名称:Windsor,代码行数:13,代码来源:IoC-115.cs

示例7: ShouldResolveDecoratedComponentFromGrandParent

 public void ShouldResolveDecoratedComponentFromGrandParent()
 {
     WindsorContainer grandParent = new WindsorContainer();
     WindsorContainer parent = new WindsorContainer();
     WindsorContainer child = new WindsorContainer();
     grandParent.AddChildContainer(parent);
     parent.AddChildContainer(child);
     ((IWindsorContainer)grandParent).Register(Component.For(typeof(IDoNothingService)).ImplementedBy(typeof(DoNothingServiceDecorator)).Named("DoNothingServiceDecorator"));
     ((IWindsorContainer)grandParent).Register(Component.For(typeof(IDoNothingService)).ImplementedBy(typeof(DoNothingService)).Named("DoNothingService"));
     IDoNothingService service = child.Resolve<IDoNothingService>();
     Assert.IsNotNull(service);
     Assert.IsInstanceOf(typeof(DoNothingServiceDecorator), service);
 }
开发者ID:gschuager,项目名称:Castle.Windsor,代码行数:13,代码来源:ConfigureDecoratorsTestCase.cs

示例8: Shows_also_components_from_parent_container

		public void Shows_also_components_from_parent_container()
		{
			var parent = new WindsorContainer();
			parent.Register(Component.For<A>(),
			                Component.For<B>());
			Container.Register(Component.For(typeof(IGeneric<>)).ImplementedBy(typeof(GenericImpl1<>)),
			                   Component.For(typeof(IGeneric<>)).ImplementedBy(typeof(GenericImpl2<>)));

			parent.AddChildContainer(Container);

			var handlers = diagnostic.Inspect();

			Assert.AreEqual(4, handlers.Length);
		}
开发者ID:RookieX,项目名称:Windsor,代码行数:14,代码来源:AllComponentsDiagnosticTestCase.cs

示例9: Should_resolve_child_from_childs_container

        public void Should_resolve_child_from_childs_container()
        {
            WindsorContainer parent = new WindsorContainer();
            WindsorContainer child = new WindsorContainer();

            parent.AddChildContainer(child);

            ((IWindsorContainer)parent).Register(Component.For(typeof(IParentService)).ImplementedBy(typeof(ParentService)).Named("service1"));
            ((IWindsorContainer)parent).Register(Component.For(typeof(IChildService2)).ImplementedBy(typeof(ChildService2)).Named("service3"));
            ((IWindsorContainer)child).Register(Component.For(typeof(IParentService)).ImplementedBy(typeof(AnotherParentService)).Named("service2"));

			IChildService2 resolve = child.Resolve<IChildService2>();
            Assert.IsInstanceOf(typeof(AnotherParentService),resolve.Parent);
        }
开发者ID:gschuager,项目名称:Castle.Windsor,代码行数:14,代码来源:IoC-115.cs

示例10: Should_resolve_child_from_childs_container

        public void Should_resolve_child_from_childs_container()
        {
            WindsorContainer parent = new WindsorContainer();
            WindsorContainer child = new WindsorContainer();

            parent.AddChildContainer(child);

            parent.AddComponent("service1", typeof(IParentService), typeof(ParentService));
            parent.AddComponent("service3", typeof(IChildService2), typeof(ChildService2));
            child.AddComponent("service2", typeof(IParentService), typeof(AnotherParentService));

			IChildService2 resolve = child.Resolve<IChildService2>();
            Assert.IsInstanceOf(typeof(AnotherParentService),resolve.Parent);
        }
开发者ID:AGiorgetti,项目名称:Castle.InversionOfControl,代码行数:14,代码来源:IoC-115.cs

示例11: Cannot_resolve_a_dependency_from_a_parent_container_under_certain_circumstances

        public void  Cannot_resolve_a_dependency_from_a_parent_container_under_certain_circumstances()
        {
            WindsorContainer parent = new WindsorContainer();
            WindsorContainer child = new WindsorContainer();

            parent.AddChildContainer(child);

            parent.AddComponent("service", typeof(IParentService), typeof(ParentService));
            child.AddComponent("service1", typeof(IChildService1), typeof(ChildService1));
            child.AddComponent("service2", typeof(IChildService2), typeof(ChildService2));


            child.Resolve<IChildService1>();
        }
开发者ID:AGiorgetti,项目名称:Castle.InversionOfControl,代码行数:14,代码来源:IoC-115.cs

示例12: AddComponentInstanceAndChildContainers

		public void AddComponentInstanceAndChildContainers()
		{
			IWindsorContainer parent = new WindsorContainer();
			IWindsorContainer child = new WindsorContainer();
			parent.AddChildContainer(child);

			IEmptyService clock1 = new EmptyServiceA();
			IEmptyService clock2 = new EmptyServiceB();

			parent.Kernel.Register(Component.For(typeof(IEmptyService)).Instance(clock2));
			child.Kernel.Register(Component.For(typeof(IEmptyService)).Instance(clock1));

			Assert.AreSame(clock2, parent.Resolve<IEmptyService>());
			Assert.AreSame(clock1, child.Resolve<IEmptyService>());
		}
开发者ID:n2cms,项目名称:Castle.Windsor,代码行数:15,代码来源:IoC-127.cs

示例13: TestForSerivces

		public void TestForSerivces()
		{
			using (var container = new WindsorContainer())
			{
				container.Register(Component.For<IInterface>().ImplementedBy<InterfaceImpl>());
				IInterface childInterface;
				using (var childContainer = new WindsorContainer())
				{
					container.AddChildContainer(childContainer);
					childInterface = container.Resolve<IInterface>();
				} // childIhterface is NOT disposing here
				var @interface = container.Resolve<IInterface>();
				Assert.AreSame(@interface, childInterface);
				@interface.Do();
			} // but is disposing here and this is right behavior
		}
开发者ID:RookieX,项目名称:Windsor,代码行数:16,代码来源:LifestyleTests.cs

示例14: AddComponentInstanceAndChildContainers

        public void AddComponentInstanceAndChildContainers()
        {
            IWindsorContainer parent = new WindsorContainer();
            IWindsorContainer child = new WindsorContainer();
            parent.AddChildContainer(child);

            IClock clock1 = new IsraelClock();
            IClock clock2 = new WorldClock();

            parent.Kernel.AddComponentInstance<IClock>(clock2);
            child.Kernel.AddComponentInstance<IClock>(clock1);

            Assert.AreSame(clock2,parent.Resolve<IClock>());
            Assert.AreSame(clock1, child.Resolve<IClock>());

        }
开发者ID:ralescano,项目名称:castle,代码行数:16,代码来源:IoC-127.cs

示例15: TestForTypedFactories

		public void TestForTypedFactories()
		{
			using (var container = new WindsorContainer())
			{
				container.AddFacility<TypedFactoryFacility>();
				container.Register(Component.For<IFactory>().AsFactory(),
				                   Component.For(typeof(IInterface)).ImplementedBy(typeof(InterfaceImpl)).LifeStyle.Transient);

				IFactory childFactory;
				using (var childContainer = new WindsorContainer())
				{
					container.AddChildContainer(childContainer);
					childFactory = childContainer.Resolve<IFactory>();
				} // childFactory is disposing here
				var factory = container.Resolve<IFactory>();
				Assert.AreSame(factory, childFactory);
				Assert.DoesNotThrow(() => factory.Create()); // throws an ObjectDisposedException exception
			} // but should be disposed here
		}
开发者ID:RookieX,项目名称:Windsor,代码行数:19,代码来源:LifestyleTests.cs


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