private SignatureWriter(TextWriter writer, Tree tree) { _writer = writer; _tree = tree; _typeMap = tree.Types.ToDictionary(n => n.Name, n => n.Base); _typeMap.Add(tree.Root, null); }
protected AbstractFileWriter(TextWriter writer, Tree tree) { _writer = writer; _tree = tree; _nodeMap = tree.Types.OfType<Node>().ToDictionary(n => n.Name); _parentMap = tree.Types.ToDictionary(n => n.Name, n => n.Base); _parentMap.Add(tree.Root, null); _childMap = tree.Types.ToLookup(n => n.Base, n => n.Name); }
public static void WriteSyntax(TextWriter writer, Tree tree) => new SourceWriter(writer, tree).WriteSyntax();
public static void WriteInternal(TextWriter writer, Tree tree) => new SourceWriter(writer, tree).WriteInternal();
public static void WriteMain(TextWriter writer, Tree tree) => new SourceWriter(writer, tree).WriteMain();
private SourceWriter(TextWriter writer, Tree tree) : base(writer, tree) { }
private TestWriter(TextWriter writer, Tree tree) : base(writer, tree) { }
public static void Write(TextWriter writer, Tree tree) { new TestWriter(writer, tree).WriteFile(); }
private static void WriteToFile(Tree tree, Action<TextWriter, Tree> writeAction, string outputFile) { var stringBuilder = new StringBuilder(); var writer = new StringWriter(stringBuilder); writeAction(writer, tree); var text = stringBuilder.ToString(); int length; do { length = text.Length; text = text.Replace("{\r\n\r\n", "{\r\n"); } while (text.Length != length); try { using (var outFile = new StreamWriter(File.Open(outputFile, FileMode.Create))) { outFile.Write(text); } Console.WriteLine("Wrote {0}", outputFile); } catch (UnauthorizedAccessException) { Console.WriteLine("Unable to access {0}. Is it checked out?", outputFile); } }
public static void Write(TextWriter writer, Tree tree) { new SignatureWriter(writer, tree).WriteFile(); }
private TestWriter(TextWriter writer, Tree tree) : base(writer, tree) { }
public static void Write(TextWriter writer, Tree tree) { new TestWriter(writer, tree).WriteFile(); }
public static void Main(string[] args) { if (args.Length < 2 || args.Length > 3) { WriteUsage(); return; } string inputFile = args[0]; if (!File.Exists(inputFile)) { Console.WriteLine(inputFile + " not found."); return; } bool writeSource = true; bool writeTests = false; bool writeSignatures = false; string outputFile = null; if (args.Length == 3) { outputFile = args[1]; if (args[2] == "/test") { writeTests = true; writeSource = false; } else { WriteUsage(); return; } } else if (args.Length == 2) { if (args[1] == "/sig") { writeSignatures = true; } else { outputFile = args[1]; } } var reader = new XmlTextReader(inputFile); var serializer = new XmlSerializer(typeof(Tree)); Tree tree = (Tree)serializer.Deserialize(reader); if (writeSignatures) { SignatureWriter.Write(Console.Out, tree); } else { if (writeSource) { WriteToFile(tree, SourceWriter.Write, outputFile); } if (writeTests) { WriteToFile(tree, TestWriter.Write, outputFile); } } }
public static void Write(TextWriter writer, Tree tree) { new SignatureWriter(writer, tree).WriteFile(); }