/// <summary> /// Creates a new import stream. /// </summary> /// <param name="type">Type of import stream.</param> /// <param name="streamName">Name of stream in MSI/MSM.</param> /// <param name="path">Path to file to import.</param> public ImportStream(ImportStreamType type, string streamName, string path) { this.type = type; this.streamName = streamName; this.path = path; }
/// <summary> /// Processes an XmlReader and builds up the import stream object. /// </summary> /// <param name="reader">Reader to get data from.</param> /// <returns>Import stream object.</returns> internal static ImportStream Parse(XmlReader reader) { Debug.Assert("importStream" == reader.LocalName); string name = null; string streamPath = null; ImportStreamType type = ImportStreamType.Unknown; bool empty = reader.IsEmptyElement; while (reader.MoveToNextAttribute()) { switch (reader.LocalName) { case "name": name = reader.Value; break; case "path": streamPath = reader.Value; break; case "type": switch (reader.Value) { case "Binary": type = ImportStreamType.Binary; break; case "Cabinet": type = ImportStreamType.Cabinet; break; case "Icon": type = ImportStreamType.Icon; break; case "DigitalCertificate": type = ImportStreamType.DigitalCertificate; break; default: throw new WixParseException(String.Format("The importStream/@type attribute contains an unexpected value '{0}'.", reader.Value)); } break; default: throw new WixParseException(String.Format("The importStream element contains an unexpected child element {0}.", reader.Name)); } } if (null == name) { throw new WixParseException("The importStream/@name attribute was not found; it is required."); } if (null == streamPath) { throw new WixParseException("The importStream/@path attribute was not found; it is required."); } if (ImportStreamType.Unknown == type) { throw new WixParseException("The importStream/@type attribute was not found; it is required."); } // ensure there are no child elements if (!empty) { throw new WixParseException("The importStream element contains text or other elements; it cannot."); } return(new ImportStream(type, name, streamPath)); }
/// <summary> /// Processes an XmlReader and builds up the import stream object. /// </summary> /// <param name="reader">Reader to get data from.</param> /// <returns>Import stream object.</returns> internal static ImportStream Parse(XmlReader reader) { Debug.Assert("importStream" == reader.LocalName); string name = null; string streamPath = null; ImportStreamType type = ImportStreamType.Unknown; bool empty = reader.IsEmptyElement; while (reader.MoveToNextAttribute()) { switch (reader.LocalName) { case "name": name = reader.Value; break; case "path": streamPath = reader.Value; break; case "type": switch (reader.Value) { case "Binary": type = ImportStreamType.Binary; break; case "Cabinet": type = ImportStreamType.Cabinet; break; case "Icon": type = ImportStreamType.Icon; break; case "DigitalCertificate": type = ImportStreamType.DigitalCertificate; break; default: throw new WixParseException(String.Format("The importStream/@type attribute contains an unexpected value '{0}'.", reader.Value)); } break; default: throw new WixParseException(String.Format("The importStream element contains an unexpected child element {0}.", reader.Name)); } } if (null == name) { throw new WixParseException("The importStream/@name attribute was not found; it is required."); } if (null == streamPath) { throw new WixParseException("The importStream/@path attribute was not found; it is required."); } if (ImportStreamType.Unknown == type) { throw new WixParseException("The importStream/@type attribute was not found; it is required."); } // ensure there are no child elements if (!empty) { throw new WixParseException("The importStream element contains text or other elements; it cannot."); } return new ImportStream(type, name, streamPath); }