// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. namespace WixToolset.Data { using System.Xml; /// /// Substorage inside an output. /// public sealed class SubStorage { /// /// Instantiate a new substorage. /// /// The substorage name. /// The substorage data. public SubStorage(string name, Output data) { this.Name = name; this.Data = data; } /// /// Gets the substorage name. /// /// The substorage name. public string Name { get; private set; } /// /// Gets the substorage data. /// /// The substorage data. public Output Data { get; private set; } /// /// Creates a SubStorage from the XmlReader. /// /// Reader to get data from. /// New SubStorage object. internal static SubStorage Read(XmlReader reader) { if (!reader.LocalName.Equals("subStorage" == reader.LocalName)) { throw new XmlException(); } Output data = null; bool empty = reader.IsEmptyElement; string name = null; while (reader.MoveToNextAttribute()) { switch (reader.LocalName) { case "name": name = reader.Value; break; } } if (!empty) { bool done = false; while (!done && reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: switch (reader.LocalName) { case "wixOutput": data = Output.Read(reader, true); break; default: throw new XmlException(); } break; case XmlNodeType.EndElement: done = true; break; } } if (!done) { throw new XmlException(); } } return new SubStorage(name, data); } /// /// Persists a SubStorage in an XML format. /// /// XmlWriter where the SubStorage should persist itself as XML. internal void Write(XmlWriter writer) { writer.WriteStartElement("subStorage", Output.XmlNamespaceUri); writer.WriteAttributeString("name", this.Name); this.Data.Write(writer); writer.WriteEndElement(); } } }