Example #1
0
 /// <summary>
 /// Write output as interpretation result
 /// </summary>
 /// <param name="w">writer</param>
 /// <param name="indentValue">space size</param>
 /// <param name="currentLine">in-progress line add</param>
 /// <param name="config">configuration</param>
 public void Execute(TextWriter w, ref int indentValue, ref string currentLine, Configuration config)
 {
     foreach (string e in this.Strings)
     {
         if (e.StartsWith("[") && e.EndsWith("]"))
         {
             string r = e.Substring(1, e.Length - 2);
             r = config.Execute(r);
             if (this.ExistTestVariable(r))
             {
                 this.Variables[r].Execute(w, ref indentValue, ref currentLine, config, this.CurrentDirectory);
             }
         }
         else
         {
             string val = config.Execute(e);
             PrinterObject.IndentSource(w, indentValue, ref currentLine, val);
         }
     }
 }
 /// <summary>
 /// Execute the variable
 /// </summary>
 /// <param name="w">writer</param>
 /// <param name="indentValue">space size</param>
 /// <param name="currentLine">in-progress line add</param>
 /// <param name="config">configuration</param>
 /// <param name="dir">directory</param>
 public void Execute(TextWriter w, ref int indentValue, ref string currentLine, Configuration config, string dir)
 {
     if (this.Indent)
     {
         ++indentValue;
     }
     if (this.Include)
     {
         string   fileName = config.Execute(this.Value);
         FileInfo fi       = new FileInfo(Path.Combine(dir, fileName));
         if (fi.Exists)
         {
             using (FileStream fs = fi.Open(FileMode.Open, FileAccess.Read, FileShare.Read))
             {
                 PrinterObject po = PrinterObject.Load(fs);
                 po.CurrentDirectory = dir;
                 foreach (PrinterVariable pv in this.Values)
                 {
                     po.AddVariable(pv.Name, pv);
                 }
                 po.ImportConfiguration(config);
                 po.Execute(w, ref indentValue, ref currentLine, po.Configuration);
                 fs.Close();
             }
         }
     }
     else
     {
         if (!String.IsNullOrEmpty(this.Value))
         {
             string val = config.Execute(this.Value);
             PrinterObject.IndentSource(w, indentValue, ref currentLine, val);
         }
     }
     if (this.Indent)
     {
         --indentValue;
     }
 }