Example #1
0
 public override void  Append(ref Dictionary<string,object> variables, Org.Reddragonit.Stringtemplate.Outputs.IOutputWriter writer)
 {
     object obj = Utility.LocateObjectInVariables(_variable, variables);
     _format = (Utility.LocateObjectInVariables(_format, variables) != null ? Utility.LocateObjectInVariables(_format, variables) : _format).ToString();
     if (obj != null)
         writer.Append(((IFormattable)Utility.LocateObjectInVariables(_variable, variables)).ToString(_format, null));
 }
Example #2
0
 public override void Append(ref Dictionary<string, object> variables, Org.Reddragonit.Stringtemplate.Outputs.IOutputWriter writer)
 {
     object obj = Utility.LocateObjectInVariables(val, variables);
     if (obj == null)
         throw new Exception("Unable to locate a variable of the name " + val + " in order to extract the type name");
     writer.Append(obj.GetType().FullName);
 }
Example #3
0
 public override void Append(ref Dictionary<string, object> variables, Org.Reddragonit.Stringtemplate.Outputs.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(true.ToString());
         else
             writer.Append(false.ToString());
     }
     else
         writer.Append(false.ToString());
 }
Example #4
0
 public override void Append(ref Dictionary<string, object> variables, Org.Reddragonit.Stringtemplate.Outputs.IOutputWriter writer)
 {
     StringOutputWriter swo = new StringOutputWriter();
     _eval.Append(ref variables,swo);
     string tmp = swo.ToString();
     swo.Clear();
     _search.Append(ref variables, swo);
     string search = swo.ToString();
     swo.Clear();
     _replace.Append(ref variables, swo);
     string replace = swo.ToString();
     if ((tmp != null)&&(search!=null)&&(replace!=null))
     {
         if (search.StartsWith("\"") && search.EndsWith("\""))
             search = search.Substring(1, search.Length - 2);
         else if (search.StartsWith("'") && search.EndsWith("'"))
             search = search.Substring(1, search.Length - 2);
         if (replace.StartsWith("\"") && replace.EndsWith("\""))
             replace = replace.Substring(1, replace.Length - 2);
         else if (replace.StartsWith("'") && replace.EndsWith("'"))
             replace = replace.Substring(1, replace.Length - 2);
         writer.Append(tmp.Replace(search, replace));
     }
 }