Ejemplo n.º 1
0
        /// <summary>
        /// Returns a stream over the update XML metadata
        /// </summary>
        /// <param name="updateId">The update ID to get XML metadata for</param>
        /// <returns>Stream of the XML metadata</returns>
        public Stream GetUpdateMetadataStream(Metadata.Identity updateId)
        {
            if (InputFile == null)
            {
                throw new Exception("Query result is not in read mode");
            }

            if (IsDeltaSource && BaselineIdentities.Contains(updateId))
            {
                return(BaselineSource.GetUpdateMetadataStream(updateId));
            }
            else
            {
                var entryIndex = InputFile.FindEntry(GetUpdateXmlPath(updateId), true);
                if (entryIndex < 0)
                {
                    throw new KeyNotFoundException();
                }

                return(InputFile.GetInputStream(entryIndex));
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Returns an index for an update (number between 0 and 255) based on the update\s ID.
 /// </summary>
 /// <param name="updateId">The update to get the index for</param>
 /// <returns>String representation of the index</returns>
 private static string GetUpdateIndex(Metadata.Identity updateId)
 {
     // The index is the last 8 bits of the update ID.
     return(updateId.Raw.UpdateID.ToByteArray().Last().ToString());
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Returns the path to the update XML in query result ZIP archive
 /// </summary>
 /// <param name="updateId">The update to get the path for.</param>
 /// <returns>A fully qualified path to the XML file belonging to the specified update</returns>
 private string GetUpdateXmlPath(Metadata.Identity updateId)
 {
     return($"{GetUpdateIndex(updateId)}/{updateId.ToString()}.xml");
 }