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); } }
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); } }
public void Execute(ToffeeWriter writer) { switch (Command.ToLower()) { case "indent": string argument = Argument.ToLower(); if (argument == "forwards") { writer.IndentLevel++; } else if (argument == "backwards") { writer.IndentLevel--; } else if (argument == "on") { writer.Indent = true; } else if (argument == "off") { writer.Indent = false; } break; case "newline": if (Argument == "0") { writer.AppendNewline = false; } else { writer.AppendNewline = true; } break; case "crash": throw new ToffeeWriterException("Writer was told to crash."); default: writer.Log("Unknown writer command '{0}'", Command); break; } }
public void Execute(ToffeeWriter writer) { if (Not) { writer.Log("Checking if '{0}' is not defined", Define); if (!writer.Defines.Contains(Define)) { writer.Log("'{0}' was not defined, entering TrueCode", Define); foreach (IGeneratorCommand command in TrueCode) { command.Execute(writer); } } else { writer.Log("'{0}' was defined, entering FalseCode", Define); foreach (IGeneratorCommand command in FalseCode) { command.Execute(writer); } } } else { writer.Log("Checking if '{0}' is defined", Define); if (writer.Defines.Contains(Define)) { writer.Log("'{0}' was defined, entering TrueCode", Define); foreach (IGeneratorCommand command in TrueCode) { command.Execute(writer); } } else { writer.Log("'{0}' was not defined, entering FalseCode", Define); foreach (IGeneratorCommand command in FalseCode) { command.Execute(writer); } } } writer.Log("Left Code for '{0}'", Define); }