本文整理汇总了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));
}
示例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);
}
}
}