From 2bb37beda887d120a0ddabf874ad25357101faa1 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Wed, 1 Nov 2017 10:59:45 -0700 Subject: Update to WiX Intermediate Representation --- src/WixToolset.Data.WindowsInstaller/SubStorage.cs | 109 +++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 src/WixToolset.Data.WindowsInstaller/SubStorage.cs (limited to 'src/WixToolset.Data.WindowsInstaller/SubStorage.cs') diff --git a/src/WixToolset.Data.WindowsInstaller/SubStorage.cs b/src/WixToolset.Data.WindowsInstaller/SubStorage.cs new file mode 100644 index 00000000..e136bfe9 --- /dev/null +++ b/src/WixToolset.Data.WindowsInstaller/SubStorage.cs @@ -0,0 +1,109 @@ +// 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(); + } + } +} -- cgit v1.2.3-55-g6feb