Example #1
0
        /// <summary>
        /// Gets the page ranges impl.
        /// </summary>
        /// <param name="options">An object that specifies any additional options for the request.</param>
        /// <param name="setResult">The set result.</param>
        /// <returns>A <see cref="TaskSequence"/> for getting the page ranges.</returns>
        private TaskSequence GetPageRangesImpl(BlobRequestOptions options, Action <IEnumerable <PageRange> > setResult)
        {
            CommonUtils.AssertNotNull("options", options);

            var webRequest = ProtocolHelper.GetWebRequest(this.ServiceClient, options, (timeout) => BlobRequest.GetPageRanges(this.TransformedAddress, timeout, this.SnapshotTime, null));

            BlobRequest.AddMetadata(webRequest, this.Metadata);
            this.ServiceClient.Credentials.SignRequest(webRequest);
            var task = webRequest.GetResponseAsyncWithTimeout(this.ServiceClient, options.Timeout);

            yield return(task);

            using (var webResponse = task.Result as HttpWebResponse)
            {
                var getPageRangesResponse   = BlobResponse.GetPageRanges(webResponse);
                List <PageRange> pageRanges = new List <PageRange>();

                // materialize response as we need to close the webResponse
                pageRanges.AddRange(getPageRangesResponse.PageRanges.ToList());

                setResult(pageRanges);

                this.ParseSizeAndLastModified(webResponse);
            }
        }