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


C# IKernel.GetHandlers方法代码示例

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


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

示例1: FetchHooks

		private static IPreCommit[] FetchHooks(IKernel kernel)
		{
			ArrayList list = new ArrayList();
			foreach (IHandler handler in kernel.GetHandlers(typeof(IPreCommit)))
			{
				IPreCommit hook = (IPreCommit)handler.Resolve();
				list.Add(hook);
			}

			return (IPreCommit[])list.ToArray(typeof(IPreCommit));
		}
开发者ID:atczyc,项目名称:castle,代码行数:11,代码来源:Application.cs

示例2: InspectServiceDependency

		private void InspectServiceDependency(IHandler inspectingHandler, DependencyModel dependency, IKernel kernel)
		{
			var type = dependency.TargetItemType;
			var handler = kernel.GetHandler(type);
			if (handler == null)
			{
				message.AppendFormat("- Service '{0}' which was not registered.", type.FullName ?? type.Name);
				message.AppendLine();
			}
			else if (handler == inspectingHandler)
			{
				var alternatives = kernel.GetHandlers(type);
				message.AppendFormat("- Service '{0}' which points back to the component itself.", type.FullName ?? type.Name);
				message.AppendLine();
				message.Append("A dependency cannot be satisfied by the component itself, did you forget to ");
				if (alternatives.Length == 1)
				{
					message.AppendLine("register other components for this service?");
				}
				else
				{
					message.AppendLine("make this a service override and point explicitly to a different component exposing this service?");
					message.AppendLine();
					message.Append("The following components also expose the service, but none of them can be resolved:");
					foreach (var maybeDecoratedHandler in alternatives.Where(maybeDecoratedHandler => maybeDecoratedHandler != inspectingHandler))
					{
						var info = maybeDecoratedHandler as IExposeDependencyInfo;
						if (info != null)
						{
							info.ObtainDependencyDetails(this);
						}
						else
						{
							message.AppendLine();
							message.AppendFormat("'{0}' is registered and is matching the required service, but cannot be resolved.",
												 maybeDecoratedHandler.ComponentModel.Name);
						}
					}
				}
			}
			else
			{
				message.AppendFormat("- Service '{0}' which was registered but is also waiting for dependencies.", handler.ComponentModel.Name);
				var info = handler as IExposeDependencyInfo;
				if (info != null)
				{
					info.ObtainDependencyDetails(this);
				}
			}
		}
开发者ID:thefringeninja,项目名称:Castle.Windsor,代码行数:50,代码来源:DependencyInspector.cs


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