internal static IDocumentationSerialiser GetSerialiser(string outputFilename) { string extension = GetExtension(outputFilename); IDocumentationSerialiser serialiser = null; if (extension != null) { try { if (extension.Equals("raml")) { extension = string.Concat(extension, RAMLVersion); } serialiser = Serialisers[extension]; } catch (KeyNotFoundException exception) { throw new KeyNotFoundException(string.Concat("No serialiser found for extension ", extension), exception); } } else { throw new ArgumentException(string.Concat("Invalid extension in output filename: ", outputFilename)); } return(serialiser); }
private static void GenerateDocumentation(ResourceNode resourceTree, DocumentationHeaderSettings headerSettings, SchemaStore schemaStore, ExampleStore exampleStore, string outputFilename) { IDocumentationSerialiser serialiser = DocumentationSerialiserFactory.GetSerialiser(outputFilename); using (FileStream stream = new FileStream(outputFilename, FileMode.Create, FileAccess.Write)) { StreamWriter streamWriter = new StreamWriter(stream); serialiser.Serialise(streamWriter, resourceTree, headerSettings, schemaStore, exampleStore); streamWriter.Flush(); } }