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


C# CreationContext.BuildCycleMessageFor方法代码示例

本文整理汇总了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();
			}
		}
开发者ID:castleproject,项目名称:Windsor,代码行数:62,代码来源:DefaultHandler.cs


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