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


C# IDependencyResolver.CanResolve方法代码示例

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


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

示例1: ObtainPropertyValue

 /// <summary>
 /// Source: http://www.symbolsource.org/Public/Metadata/NuGet/Project/Castle.Windsor/3.0.0.3001/Release/.NETFramework,Version%3Dv4.0,Profile%3DClient/Castle.Windsor/Castle.Windsor/MicroKernel/ComponentActivator/DefaultComponentActivator.cs?ImageName=Castle.Windsor
 /// </summary>
 /// <param name="context"></param>
 /// <param name="property"></param>
 /// <param name="resolver"></param>
 /// <returns></returns>
 private object ObtainPropertyValue(CreationContext context, PropertySet property, IDependencyResolver resolver)
 {
     if (property.Dependency.IsOptional == false || resolver.CanResolve(context, context.Handler, Model, property.Dependency))
     {
         try
         {
             return resolver.Resolve(context, context.Handler, Model, property.Dependency);
         }
         catch (Exception ex)
         {
             //trondr: Do not silently ignore exceptions when resolving property depencies.                    
             //if (property.Dependency.IsOptional == false)
             //{
             //    throw;
             //}
             //trondr: Rethrow the exception
             throw new ComponentActivatorException("Failed to resolve property: " + property.Property.Name , ex, Model);
         }
     }
     return null;
 }
开发者ID:trondr,项目名称:NMultiTool,代码行数:28,代码来源:StrictComponentActivator.cs

示例2: ObtainPropertyValue

		private object ObtainPropertyValue(CreationContext context, PropertySet property, IDependencyResolver resolver)
		{
			if (property.Dependency.IsOptional == false ||
			    resolver.CanResolve(context, context.Handler, Model, property.Dependency))
			{
				try
				{
					return resolver.Resolve(context, context.Handler, Model, property.Dependency);
				}
				catch (Exception)
				{
					if (property.Dependency.IsOptional == false)
					{
						throw;
					}
				}
			}
			return null;
		}
开发者ID:thefringeninja,项目名称:Castle.Windsor,代码行数:19,代码来源:DefaultComponentActivator.cs

示例3: ObtainPropertyValue

		private object ObtainPropertyValue(CreationContext context, PropertySet property, IDependencyResolver resolver)
		{
			using (new DependencyTrackingScope(context, Model, property.Property, property.Dependency))
			{
				if (property.Dependency.IsOptional == false ||
				    resolver.CanResolve(context, context.Handler, Model, property.Dependency))
				{
					return ObtainPropertyValueCore(context, property, resolver);
				}
			}
			return null;
		}
开发者ID:vbedegi,项目名称:Castle.InversionOfControl,代码行数:12,代码来源:DefaultComponentActivator.cs

示例4: ObtainPropertyValue

		private object ObtainPropertyValue(CreationContext context, PropertySet property, IDependencyResolver resolver)
		{
			if (property.Dependency.IsOptional == false ||
			    resolver.CanResolve(context, context.Handler, Model, property.Dependency))
			{
				try
				{
					return resolver.Resolve(context, context.Handler, Model, property.Dependency);
				}
				catch (Exception e)
				{
					if (property.Dependency.IsOptional == false)
					{
						throw;
					}
					Kernel.Logger.Warn(string.Format("Exception when resolving optional dependency {0} on component {1}.", property.Dependency, Model.Name), e);
				}
			}
			return null;
		}
开发者ID:dohansen,项目名称:Windsor,代码行数:20,代码来源:DefaultComponentActivator.cs


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