/// <summary> /// Writes a collection of format view definitions to XML file /// </summary> /// <param name="typeDefinitions">collection of PSTypeDefinition</param> /// <param name="filepath">path to XML file</param> /// <param name="cmdlet">cmdlet from which this si used</param> /// <param name="force">true - to force write the file</param> /// <param name="writeScriptBlock">true - to export scriptblocks</param> /// <param name="noclobber">true - do not overwrite the file</param> /// <param name="isLiteralPath">true - bypass wildcard expansion on the file name</param> internal static void WriteToPs1Xml(PSCmdlet cmdlet, List <ExtendedTypeDefinition> typeDefinitions, string filepath, bool force, bool noclobber, bool writeScriptBlock, bool isLiteralPath) { StreamWriter streamWriter; FileStream fileStream; FileInfo fileInfo; PathUtils.MasterStreamOpen(cmdlet, filepath, "ascii", true, false, force, noclobber, out fileStream, out streamWriter, out fileInfo, isLiteralPath); try { using (XmlWriter xmlWriter = XmlWriter.Create(streamWriter)) { var writer = new FormatXmlWriter { _writer = xmlWriter, _exportScriptBlock = writeScriptBlock }; writer.WriteToXml(typeDefinitions); } } finally { streamWriter.Dispose(); fileStream.Dispose(); } }
/// <summary> /// Writes a collection of format view definitions to XML file /// </summary> /// <param name="typeDefinitions">collection of PSTypeDefinition</param> /// <param name="filepath">path to XML file</param> /// <param name="cmdlet">cmdlet from which this si used</param> /// <param name="force">true - to force write the file</param> /// <param name="writeScriptBlock">true - to export scriptblocks</param> /// <param name="noclobber">true - do not overwrite the file</param> /// <param name="isLiteralPath">true - bypass wildcard expansion on the file name</param> internal static void WriteToPs1Xml(PSCmdlet cmdlet, List<ExtendedTypeDefinition> typeDefinitions, string filepath, bool force, bool noclobber, bool writeScriptBlock, bool isLiteralPath) { StreamWriter streamWriter; FileStream fileStream; FileInfo fileInfo; PathUtils.MasterStreamOpen(cmdlet, filepath, "ascii", true, false, force, noclobber, out fileStream, out streamWriter, out fileInfo, isLiteralPath); try { using (XmlWriter xmlWriter = XmlWriter.Create(streamWriter)) { var writer = new FormatXmlWriter { _writer = xmlWriter, _exportScriptBlock = writeScriptBlock }; writer.WriteToXml(typeDefinitions); } } finally { streamWriter.Dispose(); fileStream.Dispose(); } }
internal static void WriteToXml(XmlWriter writer, IEnumerable <ExtendedTypeDefinition> typeDefinitions, bool writeScriptBlock) { var formatXmlWriter = new FormatXmlWriter { _exportScriptBlock = writeScriptBlock, _writer = writer }; formatXmlWriter.WriteToXml(typeDefinitions); }
internal static void WriteToXml(XmlWriter writer, IEnumerable<ExtendedTypeDefinition> typeDefinitions, bool writeScriptBlock) { var formatXmlWriter = new FormatXmlWriter { _exportScriptBlock = writeScriptBlock, _writer = writer }; formatXmlWriter.WriteToXml(typeDefinitions); }