/// <summary> /// Creates a new file media information from a file row. /// </summary> /// <param name="fileRow">File row.</param> public FileMediaInformation(FileRow fileRow) { if (null == fileRow) { throw new ArgumentNullException("fileRow"); } this.containedInModule = false; this.fileId = fileRow.File; this.directoryId = fileRow.Directory; this.mediaId = fileRow.DiskId; this.source = fileRow.Source; this.modulePath = null; this.rowNumber = fileRow.Number; this.patchGroup = fileRow.PatchGroup; if (0 != (fileRow.Attributes & 0x002000)) { this.fileCompression = FileCompressionValue.No; } else if (0 != (fileRow.Attributes & 0x004000)) { this.fileCompression = FileCompressionValue.Yes; } else { this.fileCompression = FileCompressionValue.NotSpecified; } this.sequence = -1; }
/// <summary> /// Creates a file media information for a module. /// </summary> /// <param name="fileId">Identifier to file this media information pertains to.</param> /// <param name="directoryId">Identifier to directory file belongs to.</param> /// <param name="mediaId">Identifier to media file belongs to.</param> /// <param name="srcPath">Path file on disk.</param> /// <param name="rowNumber">Number to row.</param> /// <param name="fileCompression">Compression for file.</param> /// <param name="modulePath">The module path where this file came from.</param> /// <param name="patchGroup">The patch group for a patch-added file.</param> public FileMediaInformation(string fileId, string directoryId, int mediaId, string srcPath, int rowNumber, FileCompressionValue fileCompression, string modulePath, int patchGroup) { this.containedInModule = true; this.fileId = fileId; this.directoryId = directoryId; this.mediaId = mediaId; this.source = srcPath; this.modulePath = modulePath; this.rowNumber = rowNumber; this.patchGroup = patchGroup; this.sequence = -1; this.fileCompression = fileCompression; }
/// <summary> /// Processes an XmlReader and builds up the file media information object. /// </summary> /// <param name="reader">Reader to get data from.</param> /// <returns>File media information object.</returns> internal static FileMediaInformation Parse(XmlReader reader) { Debug.Assert("fileMediaInformation" == reader.LocalName); string fileId = null; string directoryId = null; int mediaId = -1; string srcPath = null; int rowNumber = -1; bool containedInModule = false; int patchGroup = -1; int sequence = -1; FileCompressionValue fileCompression = FileCompressionValue.NotSpecified; bool empty = reader.IsEmptyElement; while (reader.MoveToNextAttribute()) { switch (reader.LocalName) { case "fileId": fileId = reader.Value; break; case "directoryId": directoryId = reader.Value; break; case "mediaId": mediaId = Convert.ToInt32(reader.Value, CultureInfo.InvariantCulture.NumberFormat); break; case "srcPath": srcPath = reader.Value; break; case "rowNumber": rowNumber = Convert.ToInt32(reader.Value, CultureInfo.InvariantCulture.NumberFormat); break; case "inModule": containedInModule = Common.IsYes(reader.Value, null, "fileMediaInformation", "inModule", fileId); break; case "patchGroup": patchGroup = Convert.ToInt32(reader.Value, CultureInfo.InvariantCulture.NumberFormat); break; case "sequence": sequence = Convert.ToInt32(reader.Value, CultureInfo.InvariantCulture.NumberFormat); break; case "fileCompression": switch (reader.Value) { case "NotSpecified": fileCompression = FileCompressionValue.NotSpecified; break; case "No": fileCompression = FileCompressionValue.No; break; case "Yes": fileCompression = FileCompressionValue.Yes; break; default: throw new WixParseException(String.Format("The fileMediaInformation/@fileCompression attribute contains an unexpected value '{0}'.", reader.Value)); } break; default: throw new WixParseException(String.Format("The fileMediaInformation element contains an unexpected attribute {0}.", reader.Name)); } } if (null == fileId) { throw new WixParseException("The fileMediaInformation/@fileId attribute was not found; it is required."); } if (null == directoryId) { throw new WixParseException("The fileMediaInformation/@directoryId attribute was not found; it is required."); } if (!empty) { throw new WixParseException("The fileMediaInformation element contains text or other elements; it cannot."); } FileMediaInformation fmi = new FileMediaInformation(fileId, directoryId, mediaId, srcPath, rowNumber, fileCompression, null, patchGroup); fmi.containedInModule = containedInModule; fmi.sequence = sequence; return fmi; }
/// <summary> /// Processes an XmlReader and builds up the file media information object. /// </summary> /// <param name="reader">Reader to get data from.</param> /// <returns>File media information object.</returns> internal static FileMediaInformation Parse(XmlReader reader) { Debug.Assert("fileMediaInformation" == reader.LocalName); string fileId = null; string directoryId = null; int mediaId = -1; string srcPath = null; int rowNumber = -1; bool containedInModule = false; int patchGroup = -1; int sequence = -1; FileCompressionValue fileCompression = FileCompressionValue.NotSpecified; bool empty = reader.IsEmptyElement; while (reader.MoveToNextAttribute()) { switch (reader.LocalName) { case "fileId": fileId = reader.Value; break; case "directoryId": directoryId = reader.Value; break; case "mediaId": mediaId = Convert.ToInt32(reader.Value, CultureInfo.InvariantCulture.NumberFormat); break; case "srcPath": srcPath = reader.Value; break; case "rowNumber": rowNumber = Convert.ToInt32(reader.Value, CultureInfo.InvariantCulture.NumberFormat); break; case "inModule": containedInModule = Common.IsYes(reader.Value, null, "fileMediaInformation", "inModule", fileId); break; case "patchGroup": patchGroup = Convert.ToInt32(reader.Value, CultureInfo.InvariantCulture.NumberFormat); break; case "sequence": sequence = Convert.ToInt32(reader.Value, CultureInfo.InvariantCulture.NumberFormat); break; case "fileCompression": switch (reader.Value) { case "NotSpecified": fileCompression = FileCompressionValue.NotSpecified; break; case "No": fileCompression = FileCompressionValue.No; break; case "Yes": fileCompression = FileCompressionValue.Yes; break; default: throw new WixParseException(String.Format("The fileMediaInformation/@fileCompression attribute contains an unexpected value '{0}'.", reader.Value)); } break; default: throw new WixParseException(String.Format("The fileMediaInformation element contains an unexpected attribute {0}.", reader.Name)); } } if (null == fileId) { throw new WixParseException("The fileMediaInformation/@fileId attribute was not found; it is required."); } if (null == directoryId) { throw new WixParseException("The fileMediaInformation/@directoryId attribute was not found; it is required."); } if (!empty) { throw new WixParseException("The fileMediaInformation element contains text or other elements; it cannot."); } FileMediaInformation fmi = new FileMediaInformation(fileId, directoryId, mediaId, srcPath, rowNumber, fileCompression, null, patchGroup); fmi.containedInModule = containedInModule; fmi.sequence = sequence; return(fmi); }