public override bool EvaluateAsBoolean (EvaluationContext context) { return Value; }
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)); }
public override string EvaluateAsString (EvaluationContext context) { return Left.EvaluateAsString (context) + strings [Operator] + Right.EvaluateAsString (context); }
public override object EvaluateAsObject (EvaluationContext context) { return EvaluateAsString (context); }
public abstract string EvaluateAsString(EvaluationContext context);
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); } } } }
public override bool EvaluateAsBoolean (EvaluationContext context) { var ret = EvaluateAsString (context); return EvaluateStringAsBoolean (context, ret); }
public override object EvaluateAsObject(EvaluationContext context) { return(Value); }
public override string EvaluateAsString(EvaluationContext context) { // no negation for string return("!" + Negated.EvaluateAsString(context)); }
public override string EvaluateAsString(EvaluationContext context) { return(Value ? "True" : "False"); }
public override bool EvaluateAsBoolean(EvaluationContext context) { return(Value); }
public override string EvaluateAsString(EvaluationContext context) { return(Left.EvaluateAsString(context) + strings [Operator] + Right.EvaluateAsString(context)); }
public abstract object EvaluateAsObject(EvaluationContext context);
public abstract bool EvaluateAsBoolean(EvaluationContext context);
public override string EvaluateAsString (EvaluationContext context) { // no negation for string return "!" + Negated.EvaluateAsString (context); }
public override bool EvaluateAsBoolean(EvaluationContext context) { return(!Negated.EvaluateAsBoolean(context)); }
public override string EvaluateAsString (EvaluationContext context) { var ret = EvaluateAsObject (context); // FIXME: this "wrapper" is kind of hack, to prevent sequential property references such as $(X)$(Y). return ret == null ? context.Evaluator.ReplacementForMissingPropertyAndItem : context.Evaluator.Wrapper + ret.ToString () + context.Evaluator.Wrapper; }
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)); } } } }
public override bool EvaluateAsBoolean (EvaluationContext context) { return EvaluateStringAsBoolean (context, EvaluateAsString (context)); }
public override bool EvaluateAsBoolean(EvaluationContext context) { return(EvaluateStringAsBoolean(context, EvaluateAsString(context))); }
public override string EvaluateAsString (EvaluationContext context) { return Value.Name; }
public override bool EvaluateAsBoolean(EvaluationContext context) { var ret = EvaluateAsString(context); return(EvaluateStringAsBoolean(context, ret)); }
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)); }
public override string EvaluateAsString(EvaluationContext context) { return(context.Evaluator.Evaluate(this.Value.Name)); }
public abstract object EvaluateAsObject (EvaluationContext context);
public override string EvaluateAsString(EvaluationContext context) { return(Value.Name); }
public override bool EvaluateAsBoolean (EvaluationContext context) { switch (Operator) { case Operator.EQ: return string.Equals (Left.EvaluateAsString (context), Right.EvaluateAsString (context), StringComparison.OrdinalIgnoreCase); case Operator.NE: return !string.Equals (Left.EvaluateAsString (context), Right.EvaluateAsString (context), StringComparison.OrdinalIgnoreCase); case Operator.And: case Operator.Or: // evaluate first, to detect possible syntax error on right expr. var lb = Left.EvaluateAsBoolean (context); var rb = Right.EvaluateAsBoolean (context); return Operator == Operator.And ? (lb && rb) : (lb || rb); } // comparison expressions - evaluate comparable first, then compare values. var left = Left.EvaluateAsObject (context); var right = Right.EvaluateAsObject (context); if (!(left is IComparable && right is IComparable)) throw new InvalidProjectFileException ("expression cannot be evaluated as boolean"); var result = ((IComparable) left).CompareTo (right); switch (Operator) { case Operator.GE: return result >= 0; case Operator.GT: return result > 0; case Operator.LE: return result <= 0; case Operator.LT: return result < 0; } throw new InvalidOperationException (); }
public override bool EvaluateAsBoolean(EvaluationContext context) { throw new InvalidProjectFileException("raw string literal cannot be evaluated as boolean"); }
public override string EvaluateAsString (EvaluationContext context) { return Value ? "True" : "False"; }
public override object EvaluateAsObject(EvaluationContext context) { return(EvaluateAsString(context)); }
public override object EvaluateAsObject (EvaluationContext context) { return Value; }
public override string EvaluateAsString(EvaluationContext context) { throw new NotImplementedException(); }
public override bool EvaluateAsBoolean (EvaluationContext context) { return !Negated.EvaluateAsBoolean (context); }
public override object EvaluateAsObject(EvaluationContext context) { throw new NotImplementedException(); }
public override object EvaluateAsObject (EvaluationContext context) { try { return DoEvaluateAsObject (context); } catch (TargetInvocationException ex) { throw new InvalidProjectFileException ("Access to property caused an error", ex); } }
public override string EvaluateAsString (EvaluationContext context) { return QuoteChar + EvaluateAsStringWithoutQuote (context) + QuoteChar; }
public override string EvaluateAsString (EvaluationContext context) { string itemType = Application.Name.Name; var items = context.GetItems (itemType); if (!items.Any ()) return context.Evaluator.ReplacementForMissingPropertyAndItem; if (Application.Expressions == null) return string.Join (";", items.Select (item => context.EvaluateItem (itemType, item))); else return string.Join (";", items.Select (item => { context.ContextItem = item; var ret = string.Concat (Application.Expressions.Select (e => e.EvaluateAsString (context))); context.ContextItem = null; return ret; })); }
public string EvaluateAsStringWithoutQuote (EvaluationContext context) { return string.Concat (Contents.Select (e => e.EvaluateAsString (context))); }
public override string EvaluateAsString (EvaluationContext context) { string itemType = this.Access.ItemType != null ? this.Access.ItemType.Name : null; string metadataName = Access.Metadata.Name; IEnumerable<object> items; if (this.Access.ItemType != null) items = context.GetItems (itemType); else if (context.ContextItem != null) items = new Object [] { context.ContextItem }; else items = context.GetAllItems (); var values = items.Select (i => (i is ProjectItem) ? ((ProjectItem) i).GetMetadataValue (metadataName) : ((ProjectItemInstance) i).GetMetadataValue (metadataName)).Where (s => !string.IsNullOrEmpty (s)); return string.Join (";", values); }
public override string EvaluateAsString (EvaluationContext context) { var ret = EvaluateAsObject (context); return ret == null ? null : ret.ToString (); }
public override string EvaluateAsString (EvaluationContext context) { return context.Evaluator.Evaluate (this.Value.Name); }
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; })); }
public override bool EvaluateAsBoolean (EvaluationContext context) { throw new InvalidProjectFileException ("raw string literal cannot be evaluated as boolean"); }
public abstract string EvaluateAsString (EvaluationContext context);
public override string EvaluateAsString (EvaluationContext context) { throw new NotImplementedException (); }
public abstract bool EvaluateAsBoolean (EvaluationContext context);
public override object EvaluateAsObject (EvaluationContext context) { throw new NotImplementedException (); }
public override string EvaluateAsString(EvaluationContext context) { var ret = EvaluateAsObject(context); return(ret == null ? null : ret.ToString()); }