/// <summary> /// /// </summary> /// <param name="mamlCommands"></param> /// <param name="skipPreambula">Don't include header and footer for xml doc</param> /// <returns></returns> public string MamlModelToString(IEnumerable <MamlCommand> mamlCommands, bool skipPreambula) { _stringBuilder.Clear(); if (!skipPreambula) { _stringBuilder.AppendLine(XML_PREAMBULA); } AddCommands(mamlCommands); if (!skipPreambula) { _stringBuilder.AppendLine("</helpItems>"); } return(RenderCleaner.NormalizeWhitespaces(_stringBuilder.ToString())); }
/// <summary> /// /// </summary> /// <param name="mamlCommands"></param> /// <param name="skipPreambula">Don't include header and footer for xml doc</param> /// <returns></returns> public string MamlModelToString(IEnumerable <MamlCommand> mamlCommands) { var document = new XDocument( new XDeclaration("1.0", "utf-8", null), new XElement(mshNS + "helpItems", new XAttribute("schema", "maml"), mamlCommands.Select(CreateCommandElement))); var memoryStream = new MemoryStream(); using (var writer = new StreamWriter(memoryStream, Encoding.UTF8)) { document.Save(writer, SaveOptions.OmitDuplicateNamespaces); writer.Flush(); memoryStream.Seek(0, SeekOrigin.Begin); using (var reader = new StreamReader(memoryStream, Encoding.UTF8)) { return(RenderCleaner.NormalizeWhitespaces(reader.ReadToEnd())); } } }
private string MamlModelToString(MamlCommand mamlCommand, Hashtable yamlHeader, bool skipYamlHeader) { // clear, so we can re-use this instance _stringBuilder.Clear(); if (!skipYamlHeader) { if (yamlHeader == null) { yamlHeader = new Hashtable(); } // put version there yamlHeader["schema"] = "2.0.0"; AddYamlHeader(yamlHeader); } AddCommand(mamlCommand); // at the end, just normalize all ends return(RenderCleaner.NormalizeLineBreaks( RenderCleaner.NormalizeWhitespaces( RenderCleaner.NormalizeQuotesAndDashes( _stringBuilder.ToString())))); }