protected ParseSizeAndLastModified ( |
||
response | The response to parse. | |
리턴 | void |
/// <summary> /// Implementation for the CreateSnapshot method. /// </summary> /// <param name="metadata">A collection of name-value pairs defining the metadata of the snapshot, or null.</param> /// <param name="options">An object that specifies any additional options for the request.</param> /// <param name="setResult">The result report delegate.</param> /// <returns>A <see cref="TaskSequence"/> that creates the snapshot.</returns> /// <remarks>If the <c>metadata</c> parameter is <c>null</c> then no metadata is associated with the request.</remarks> private TaskSequence CreateSnapshotImpl(NameValueCollection metadata, BlobRequestOptions options, Action<CloudBlob> setResult) { CommonUtils.AssertNotNull("options", options); var webRequest = ProtocolHelper.GetWebRequest( this.ServiceClient, options, (timeout) => BlobRequest.Snapshot(this.TransformedAddress, timeout)); BlobAttributes snapshotAttributes = new BlobAttributes(this.attributes); // If metadata was supplied it should be passed to the request. // Otherwise, no metadata should be sent. if (metadata != null) { BlobRequest.AddMetadata(webRequest, metadata); // Update the snapshot's attributes to reflect the new metadata. snapshotAttributes.Metadata.Clear(); snapshotAttributes.Metadata.Add(metadata); } this.ServiceClient.Credentials.SignRequest(webRequest); var task = webRequest.GetResponseAsyncWithTimeout(this.ServiceClient, options.Timeout); yield return task; using (var webResponse = task.Result as HttpWebResponse) { string snapshotTime = BlobResponse.GetSnapshotTime(webResponse); CloudBlob snapshot = new CloudBlob(snapshotAttributes, this.ServiceClient, snapshotTime); snapshot.ParseSizeAndLastModified(webResponse); setResult(snapshot); } }