本文整理汇总了C#中Castle.MicroKernel.Context.CreationContext.BuildCycleMessageFor方法的典型用法代码示例。如果您正苦于以下问题:C# CreationContext.BuildCycleMessageFor方法的具体用法?C# CreationContext.BuildCycleMessageFor怎么用?C# CreationContext.BuildCycleMessageFor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Castle.MicroKernel.Context.CreationContext
的用法示例。
在下文中一共展示了CreationContext.BuildCycleMessageFor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResolveCore
/// <summary>
/// Returns an instance of the component this handler
/// is responsible for
/// </summary>
/// <param name = "context"> </param>
/// <param name = "requiresDecommission"> </param>
/// <param name = "instanceRequired"> </param>
/// <param name = "burden"> </param>
/// <returns> </returns>
protected object ResolveCore(CreationContext context, bool requiresDecommission, bool instanceRequired, out Burden burden)
{
if (IsBeingResolvedInContext(context))
{
var cache = lifestyleManager as IContextLifestyleManager;
if (cache != null)
{
var instance = cache.GetContextInstance(context);
if (instance != null)
{
burden = null;
return instance;
}
}
if (instanceRequired == false)
{
burden = null;
return null;
}
var message = new StringBuilder();
message.AppendFormat("Dependency cycle has been detected when trying to resolve component '{0}'.",
ComponentModel.Name);
message.AppendLine();
message.AppendLine("The resolution tree that resulted in the cycle is the following:");
context.BuildCycleMessageFor(this, message);
throw new CircularDependencyException(message.ToString(), ComponentModel);
}
if (CanResolvePendingDependencies(context) == false)
{
if (instanceRequired == false)
{
burden = null;
return null;
}
AssertNotWaitingForDependency();
}
try
{
using (var ctx = context.EnterResolutionContext(this, requiresDecommission))
{
var instance = lifestyleManager.Resolve(context, context.ReleasePolicy);
burden = ctx.Burden;
return instance;
}
}
catch (NoResolvableConstructorFoundException)
{
throw UnresolvableHandlerException();
}
}