public static void WriteToFile(Specification spec, string file) { var stream = new MemoryStream(); try { var writer = new StreamWriter(stream); var mdWriter = new MarkdownWriter(writer); mdWriter.Write(spec); writer.Flush(); stream.Position = 0; if (stream.Length > 0) { using (var fileStream = new FileStream(file, FileMode.Create)) { stream.CopyTo(fileStream); } } } catch (Exception e) { ConsoleWriter.Write($"There was some kind of problem persisting {file}"); ConsoleWriter.Write(ConsoleColor.Yellow, e.ToString()); } }
public static string WriteToText(Specification specification) { var text = new StringWriter(); var writer = new MarkdownWriter(text); writer.Write(specification); return(text.ToString()); }
public static string WriteToText(Specification specification) { var text = new StringWriter(); var writer = new MarkdownWriter(text); writer.Write(specification); return text.ToString(); }
public static void WriteToFile(Specification spec, string file) { using (var stream = new FileStream(file, FileMode.Create)) { var writer = new StreamWriter(stream); var mdWriter = new MarkdownWriter(writer); mdWriter.Write(spec); writer.Flush(); } }
public static void WriteToFile(Specification spec, string file) { using (var stream = new FileStream(file, FileMode.Create)) { var writer = new StreamWriter(stream); var mdWriter = new MarkdownWriter(writer); mdWriter.Write(spec); writer.Flush(); } }