public void Append(ref Dictionary<string, object> variables, IOutputWriter writer)
		{
            if (_variableName.StartsWith("!"))
            {
                bool ret = !Utility.IsComponentTrue(Utility.GenerateStringFromObject(Utility.LocateObjectInVariables(_variableName.Substring(1), variables), _seperator));
                writer.Append(ret.ToString());   
            }
            else
                writer.Append(Utility.GenerateStringFromObject(Utility.LocateObjectInVariables(_variableName, variables), _seperator));
		}
        public void Append(ref Dictionary<string, object> variables, IOutputWriter writer)
		{
			switch(_val){
				case Values.NEW_LINE:
					writer.Append("\n");
					break;
				case Values.TAB:
					writer.Append("\t");
					break;
				case Values.SPACE:
					writer.Append(" ");
					break;
			}
		}
示例#3
0
 public override void Append(ref Dictionary<string, object> variables, IOutputWriter writer){
     StringOutputWriter swo = new StringOutputWriter();
     Decimal? d = null;
     try
     {
         _val.Append(ref variables, swo);
         d = Decimal.Parse(swo.ToString());
     }
     catch (Exception e)
     {
         if (_val is GenericComponent)
         {
             swo.Clear();
             _val.Append(ref variables, swo);
             string str = Utility.GenerateStringFromObject(Utility.LocateObjectInVariables(swo.ToString(), variables));
             if (str != null)
             {
                 try
                 {
                     d = Decimal.Parse(str);
                 }
                 catch (Exception ex)
                 {
                     d = null;
                 }
             }
         }
     }
     if (d.HasValue)
     {
         if (d.Value % 2 == 0)
             writer.Append(false.ToString());
         else
             writer.Append(true.ToString());
     }else
         writer.Append(false.ToString());
 }
示例#4
0
 public override void Append(ref Dictionary<string, object> variables, IOutputWriter writer)
 {
     StringOutputWriter swo = new StringOutputWriter();
     object obj = null;
     bool found = false;
     if (_val is ParameterComponent)
         obj = ((ParameterComponent)_val).GetObjectValue(variables);
     else
     {
         found = true;
         swo.Clear();
         _val.Append(ref variables, swo);
         if (_val is GenericComponent)
         {
             obj = Utility.LocateObjectInVariables(swo.ToString(), variables);
             if (obj == null)
                 writer.Append(swo.ToString().Length.ToString());
         }
         else
             writer.Append(swo.ToString().Length.ToString());
     }
     if (obj != null)
     {
         if (obj is ArrayList)
             writer.Append(((ArrayList)obj).Count.ToString());
         else if (obj is IDictionary)
             writer.Append(((IDictionary)obj).Count.ToString());
         else if (obj is string)
             writer.Append(((string)obj).Length.ToString());
         else
         {
             int cnt = 0;
             foreach (object o in (IEnumerable)obj)
                 cnt++;
             writer.Append(cnt.ToString());
         }
     }else if (!found)
         writer.Append("-1");
 }
 public void Append(ref Dictionary<string, object> variables, IOutputWriter writer)
 {
     writer.Append(_val);
 }
 public void Append(ref Dictionary<string, object> variables, IOutputWriter writer)
 {
     string ret = "false";
     StringOutputWriter swo = new StringOutputWriter();
     _left.Append(ref variables, swo);
     string l = swo.ToString();
     swo.Clear();
     _right.Append(ref variables, swo);
     string r = swo.ToString();
     swo.Clear();
     switch (_type)
     {
         case CompareType.EQUAL:
             ret = Utility.StringsEqual(l, r).ToString();
             break;
         case CompareType.GREATER_THAN:
             if (_regNumber.IsMatch(l) && _regNumber.IsMatch(r))
                 ret = (decimal.Parse(l) > decimal.Parse(r)).ToString();
             else
                 ret = ((l != null) && ((r == null) || (l.CompareTo(r) > 0))).ToString();
             break;
         case CompareType.GREATER_THAN_OR_EQUAL_TO:
             if (_regNumber.IsMatch(l) && _regNumber.IsMatch(r))
                 ret = (decimal.Parse(l) >= decimal.Parse(r)).ToString();
             else
                 ret = (((l == null) && (r == null)) || ((l != null) && ((r == null) || (l.CompareTo(r) >= 0)))).ToString();
             break;
         case CompareType.LESS_THAN:
             if (_regNumber.IsMatch(l) && _regNumber.IsMatch(r))
                 ret = (decimal.Parse(l) < decimal.Parse(r)).ToString();
             else
                 ret = ((r != null) && ((l == null) || l.CompareTo(r) < 0)).ToString();
             break;
         case CompareType.LESS_THAN_OR_EQUAL_TO:
             if (_regNumber.IsMatch(l) && _regNumber.IsMatch(r))
                 ret = (decimal.Parse(l) <= decimal.Parse(r)).ToString();
             else
                 ret = (((l == null) && (r == null)) || ((r != null) && ((l == null) || l.CompareTo(r) <= 0))).ToString();
             break;
         case CompareType.NOT_EQUAL:
             if (_regNumber.IsMatch(l) && _regNumber.IsMatch(r))
                 ret = (decimal.Parse(l) != decimal.Parse(r)).ToString();
             else
                 ret = (!Utility.StringsEqual(l, r)).ToString();
             break;
         case CompareType.SIMILAR_TO:
             ret = Utility.StringContainsString(l, r).ToString();
             break;
         case CompareType.NOT_SIMILAR_TO:
             ret = (!Utility.StringContainsString(l, r)).ToString();
             break;
     }
     writer.Append(ret);
 }