本文整理汇总了C#中Microsoft.Build.Internal.Expressions.EvaluationContext类的典型用法代码示例。如果您正苦于以下问题:C# EvaluationContext类的具体用法?C# EvaluationContext怎么用?C# EvaluationContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EvaluationContext类属于Microsoft.Build.Internal.Expressions命名空间,在下文中一共展示了EvaluationContext类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: EvaluateAsBoolean
public override bool EvaluateAsBoolean (EvaluationContext context)
{
if (string.Equals (Name.Name, "Exists", StringComparison.OrdinalIgnoreCase)) {
if (Arguments.Count != 1)
throw new InvalidProjectFileException (Location, "Function 'Exists' expects 1 argument");
string val = Arguments.First ().EvaluateAsString (context);
return Directory.Exists (val) || System.IO.File.Exists (val);
}
if (string.Equals (Name.Name, "HasTrailingSlash", StringComparison.OrdinalIgnoreCase)) {
if (Arguments.Count != 1)
throw new InvalidProjectFileException (Location, "Function 'HasTrailingSlash' expects 1 argument");
string val = Arguments.First ().EvaluateAsString (context);
return val.LastOrDefault () == '\\' || val.LastOrDefault () == '/';
}
throw new InvalidProjectFileException (Location, string.Format ("Unsupported function '{0}'", Name));
}
开发者ID:GirlD,项目名称:mono,代码行数:16,代码来源:ExpressionEvaluator.cs
示例2: EvaluateAsStringWithoutQuote
public string EvaluateAsStringWithoutQuote (EvaluationContext context)
{
return string.Concat (Contents.Select (e => e.EvaluateAsString (context)));
}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:4,代码来源:ExpressionEvaluator.cs
示例3: EvaluateAsString
public override string EvaluateAsString (EvaluationContext context)
{
return Value.Name;
}
开发者ID:GirlD,项目名称:mono,代码行数:4,代码来源:ExpressionEvaluator.cs
示例4: EvaluateAsObject
public override object EvaluateAsObject (EvaluationContext context)
{
return EvaluateAsString (context);
}
开发者ID:GirlD,项目名称:mono,代码行数:4,代码来源:ExpressionEvaluator.cs
示例5: EvaluateStringAsBoolean
public bool EvaluateStringAsBoolean (EvaluationContext context, string ret)
{
if (ret != null) {
if (ret.Equals ("TRUE", StringComparison.InvariantCultureIgnoreCase))
return true;
else if (ret.Equals ("FALSE", StringComparison.InvariantCultureIgnoreCase))
return false;
}
throw new InvalidProjectFileException (this.Location, string.Format ("Condition '{0}' is evaluated as '{1}' and cannot be converted to boolean", context.Source, ret));
}
开发者ID:GirlD,项目名称:mono,代码行数:10,代码来源:ExpressionEvaluator.cs
示例6: 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
示例7: EvaluateAsString
public override string EvaluateAsString (EvaluationContext context)
{
string itemType = Application.Name.Name;
var items = context.GetItems (itemType);
if (!items.Any ())
return null;
if (Application.Expressions == null)
return string.Join (";", items.Select (item => Unwrap (context.EvaluateItem (itemType, item))));
else
return string.Join (";", items.Select (item => {
context.ContextItem = item;
var ret = Unwrap (string.Concat (Application.Expressions.Select (e => e.EvaluateAsString (context))));
context.ContextItem = null;
return ret;
}));
}
开发者ID:ming871,项目名称:NoahGameFrame,代码行数:16,代码来源:ExpressionEvaluator.cs
示例8: EvaluateAsString
public override string EvaluateAsString (EvaluationContext context)
{
return QuoteChar + EvaluateAsStringWithoutQuote (context) + QuoteChar;
}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:4,代码来源:ExpressionEvaluator.cs
注:本文中的Microsoft.Build.Internal.Expressions.EvaluationContext类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论