Ejemplo n.º 1
0
        /// <summary>
        /// Creates a commit from the provided definition
        /// </summary>
        /// <param name="streamId"></param>
        /// <param name="commitDefinition"></param>
        /// <returns></returns>
        private ICommit CreateCommitFromDefinition(WrappedPageBlob blob, PageBlobCommitDefinition commitDefinition)
        {
            var startIndex     = commitDefinition.StartPage * _blobPageSize;
            var endIndex       = startIndex + commitDefinition.DataSizeBytes;
            var downloadedData = blob.DownloadBytes(startIndex, endIndex, true);

            using (var ms = new MemoryStream(downloadedData, false))
            {
                AzureBlobCommit azureBlobCommit;
                try
                { azureBlobCommit = _serializer.Deserialize <AzureBlobCommit>(ms); }
                catch (Exception ex)
                {
                    var message = string.Format("Blob with uri [{0}] is corrupt.", ((CloudPageBlob)blob).Uri);
                    Logger.Fatal(message);
                    throw new InvalidDataException(message, ex);
                }

                return(CreateCommitFromAzureBlobCommit(azureBlobCommit));
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Adds a PageBlobCommitDefinition to the end of the list.
 /// </summary>
 /// <param name="definition">The definition to be added</param>
 public void AppendPageBlobCommitDefinition(PageBlobCommitDefinition definition)
 {
     _pageBlobCommitDefinitions.Add(definition);
 }