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


C# EvaluationContext.EvaluateProperty方法代码示例

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


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

示例1: DoEvaluateAsObject

		object DoEvaluateAsObject (EvaluationContext context)
		{
			if (Access.Target == null) {
				return context.EvaluateProperty (Access.Name.Name);
			} else {
				if (this.Access.TargetType == PropertyTargetType.Object) {
					var obj = Access.Target.EvaluateAsObject (context);
					if (obj == null)
						return null;
					if (Access.Arguments != null) {
						var args = Access.Arguments.Select (e => e.EvaluateAsObject (context)).ToArray ();
						var method = FindMethod (obj.GetType (), Access.Name.Name, args);
						if (method == null)
							throw new InvalidProjectFileException (Location, string.Format ("access to undefined method '{0}' of '{1}' at {2}", Access.Name.Name, Access.Target.EvaluateAsString (context), Location));
						return method.Invoke (obj, AdjustArgsForCall (method, args));
					} else {
						var prop = obj.GetType ().GetProperty (Access.Name.Name);
						if (prop == null)
							throw new InvalidProjectFileException (Location, string.Format ("access to undefined property '{0}' of '{1}' at {2}", Access.Name.Name, Access.Target.EvaluateAsString (context), Location));
						return prop.GetValue (obj, null);
					}
				} else {
					var type = Type.GetType (Access.Target.EvaluateAsString (context));
					if (type == null)
						throw new InvalidProjectFileException (Location, string.Format ("specified type '{0}' was not found", Access.Target.EvaluateAsString (context)));
					if (Access.Arguments != null) {
						var args = Access.Arguments.Select (e => e.EvaluateAsObject (context)).ToArray ();
						var method = FindMethod (type, Access.Name.Name, args);
						if (method == null)
							throw new InvalidProjectFileException (Location, string.Format ("access to undefined static method '{0}' of '{1}' at {2}", Access.Name.Name, Access.Target.EvaluateAsString (context), Location));
						return method.Invoke (null, AdjustArgsForCall (method, args));
					} else {
						var prop = type.GetProperty (Access.Name.Name);
						if (prop == null)
							throw new InvalidProjectFileException (Location, string.Format ("access to undefined static property '{0}' of '{1}' at {2}", Access.Name.Name, Access.Target.EvaluateAsString (context), Location));
						return prop.GetValue (null, null);
					}
				}
			}
		}
开发者ID:GirlD,项目名称:mono,代码行数:40,代码来源:ExpressionEvaluator.cs


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