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