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


C# DefaultKernel.GetHandler方法代码示例

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


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

示例1: AddingDependencyToServiceWithCustomDependency

		public void AddingDependencyToServiceWithCustomDependency()
		{
			var k = new DefaultKernel();
			((IKernel)k).Register(Component.For(typeof(NeedClassWithCustomerDependency)).Named("NeedClassWithCustomerDependency"));
			((IKernel)k).Register(Component.For(typeof(HasCustomDependency)).Named("HasCustomDependency"));

			Assert.AreEqual(HandlerState.WaitingDependency, k.GetHandler("HasCustomDependency").CurrentState);

			var hash = new Dictionary<object, object>();
			hash["name"] = new CompA();
			k.RegisterCustomDependencies("HasCustomDependency", hash);
			Assert.AreEqual(HandlerState.Valid, k.GetHandler("HasCustomDependency").CurrentState);

			Assert.IsNotNull(k.Resolve(typeof(NeedClassWithCustomerDependency)));
		}
开发者ID:vbedegi,项目名称:Castle.InversionOfControl,代码行数:15,代码来源:RuntimeParametersTestCase.cs

示例2: AddingDependencyToServiceWithCustomDependency

		public void AddingDependencyToServiceWithCustomDependency()
		{
			var kernel = new DefaultKernel();
			kernel.Register(Component.For<NeedClassWithCustomerDependency>(),
			                Component.For<HasCustomDependency>().DependsOn(new Dictionary<object, object> { { "name", new CompA() } }));

			Assert.AreEqual(HandlerState.Valid, kernel.GetHandler(typeof(HasCustomDependency)).CurrentState);
			Assert.IsNotNull(kernel.Resolve(typeof(NeedClassWithCustomerDependency)));
		}
开发者ID:castleproject,项目名称:Windsor,代码行数:9,代码来源:RuntimeParametersTestCase.cs

示例3: WillAskResolverWhenTryingToResolveDependencyAfterAnotherHandlerWasRegistered

		public void WillAskResolverWhenTryingToResolveDependencyAfterAnotherHandlerWasRegistered()
		{
			FooBarResolver resolver = new FooBarResolver();

			IKernel kernel = new DefaultKernel();
			kernel.Resolver.AddSubResolver(resolver);

			kernel.AddComponent("foo", typeof(Foo));
			IHandler handler = kernel.GetHandler("foo");
			Assert.AreEqual(HandlerState.WaitingDependency, handler.CurrentState);

			resolver.Result = 15;

			kernel.RaiseHandlerRegistered(null);//should force reevaluation of state

			Assert.AreEqual(HandlerState.Valid, handler.CurrentState);
		}
开发者ID:ralescano,项目名称:castle,代码行数:17,代码来源:SubResolverTestCase.cs

示例4: WillAskResolverWhenTryingToResolveDependencyAfterAnotherHandlerWasRegistered

		public void WillAskResolverWhenTryingToResolveDependencyAfterAnotherHandlerWasRegistered()
		{
			var resolver = new FooBarResolver();

			IKernel kernel = new DefaultKernel();
			kernel.Resolver.AddSubResolver(resolver);

			kernel.Register(Component.For<Foo>());
			var handler = kernel.GetHandler(typeof(Foo));

			Assert.AreEqual(HandlerState.WaitingDependency, handler.CurrentState);

			resolver.Result = 15;

			kernel.Register(Component.For<A>());

			Assert.AreEqual(HandlerState.Valid, handler.CurrentState);
		}
开发者ID:pmcg,项目名称:Castle.Windsor,代码行数:18,代码来源:SubResolverTestCase.cs

示例5: AddingDependencyToServiceWithCustomDependency

		public void AddingDependencyToServiceWithCustomDependency()
		{
			DefaultKernel k = new DefaultKernel();
			k.AddComponent("NeedClassWithCustomerDependency",typeof(NeedClassWithCustomerDependency));
			k.AddComponent("HasCustomDependency", typeof(HasCustomDependency));

			Assert.AreEqual(HandlerState.WaitingDependency, k.GetHandler("HasCustomDependency").CurrentState);

			Hashtable hash = new Hashtable();
			hash["name"] = new CompA();
			k.RegisterCustomDependencies("HasCustomDependency", hash);
			Assert.AreEqual(HandlerState.Valid, k.GetHandler("HasCustomDependency").CurrentState);

			Assert.IsNotNull(k.Resolve(typeof(NeedClassWithCustomerDependency)));
		}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:15,代码来源:RuntimeParametersTestCase.cs


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