示例#1
0
 public void Execute(ToffeeWriter writer)
 {
     if (Command == "begin")
     {
         string filename = writer.GetLineToWrite(Argument);
         string filepath;
         if (writer.OutputDirectory != "")
         {
             filepath = Path.Combine(writer.OutputDirectory, filename);
         }
         else
         {
             filepath = Path.GetFullPath(filename);
         }
         string path = Path.GetDirectoryName(filepath);
         if (!Directory.Exists(path))
         {
             Directory.CreateDirectory(path);
         }
         writer.Log("Begin file: {0}", filepath);
         writer.Stream = new FileStream(filepath, FileMode.Create);
     }
     else if (Command == "end")
     {
         writer.Writer.Flush();
         writer.Stream.Dispose();
     }
     else
     {
         writer.Log("Unknown file command '{0}'", Command);
     }
 }
示例#2
0
        public void Execute(ToffeeWriter writer)
        {
            writer.Log("Writing {0}", Value);
            string value = writer.GetLineToWrite(Value);

            if (writer.AppendNewline)
            {
                writer.Writer.WriteLine(value);
            }
            else
            {
                writer.Writer.Write(value);
            }
        }