/// <summary>
        /// Returns an enumerable collection of tables segmented implementation.
        /// </summary>
        /// <param name="prefix">The prefix.</param>
        /// <param name="continuationToken">The continuation token.</param>
        /// <param name="pagination">The pagination.</param>
        /// <param name="lastResult">The last result.</param>
        /// <param name="setResult">The set result.</param>
        /// <returns>A sequence of tasks to do the operation.</returns>
        private TaskSequence ListTablesSegmentedImplCore(
            string prefix,
            ResultContinuation continuationToken,
            ResultPagination pagination,
            ResultSegment <TableServiceTable> lastResult,
            Action <ResultSegment <string> > setResult)
        {
            CommonUtils.AssertContinuationType(continuationToken, ResultContinuation.ContinuationType.Table);

            InvokeTaskSequenceTask <ResultSegment <TableServiceTable> > listTablesSegmentedTask;

            if (lastResult == null)
            {
                var svc   = this.GetDataServiceContext();
                var query = from table in svc.CreateQuery <TableServiceTable>(Protocol.Constants.TableServiceTablesName)
                            select table;

                if (prefix != string.Empty)
                {
                    // Append Max char to end  '{' is 1 + 'z' in AsciiTable
                    string uppperBound = prefix + '{';

                    query = query.Where((table) => table.TableName.CompareTo(prefix) >= 0 && table.TableName.CompareTo(uppperBound) < 0);
                }

                if (pagination.IsPagingEnabled)
                {
                    query = query.Take(pagination.GetNextRequestPageSize().Value);
                }

                var listTablesQuery = query.AsTableServiceQuery();

                listTablesSegmentedTask = new InvokeTaskSequenceTask <ResultSegment <TableServiceTable> >(
                    (setResultInner) =>
                    listTablesQuery.ExecuteSegmentedImpl(continuationToken, setResultInner));
            }
            else
            {
                listTablesSegmentedTask = new InvokeTaskSequenceTask <ResultSegment <TableServiceTable> >(lastResult.GetNextImpl);
            }

            yield return(listTablesSegmentedTask);

            if (GetResultOrDefault <ResultSegment <TableServiceTable> >(listTablesSegmentedTask, out lastResult))
            {
                setResult(new ResultSegment <string>(
                              lastResult.Results.Select((table) => table.TableName),
                              lastResult.HasMoreResults,
                              (setResultInner) =>
                              this.ListTablesSegmentedImplCore(prefix, lastResult.ContinuationToken, pagination, lastResult, setResultInner),
                              RetryPolicy)
                {
                    ContinuationToken = lastResult.ContinuationToken
                });
            }
            else
            {
                setResult(new ResultSegment <string>(new List <string>(), false, null, RetryPolicy));
            }
        }
 /// <summary>
 /// Begins an asynchronous operation to execute a query and return the results as a result segment.
 /// </summary>
 /// <param name="continuationToken">A continuation token returned by a previous listing operation.</param>
 /// <param name="callback">The callback delegate that will receive notification when the asynchronous operation completes.</param>
 /// <param name="state">A user-defined object that will be passed to the callback delegate.</param>
 /// <returns>An <see cref="IAsyncResult"/> that references the asynchronous operation.</returns>
 public IAsyncResult BeginExecuteSegmented(ResultContinuation continuationToken, AsyncCallback callback, object state)
 {
     return(TaskImplHelper.BeginImplWithRetry <ResultSegment <TElement> >(
                (setResult) => this.ExecuteSegmentedImpl(continuationToken, setResult),
                this.RetryPolicy,
                callback,
                state));
 }
        /// <summary>
        /// Returns an enumerable collection of tables segmented impl.
        /// </summary>
        /// <param name="prefix">The prefix.</param>
        /// <param name="maxResults">The max results.</param>
        /// <param name="continuationToken">The continuation token.</param>
        /// <param name="setResult">The set result.</param>
        /// <returns>A <see cref="TaskSequence"/> that lists the tables.</returns>
        private TaskSequence ListTablesSegmentedImpl(
            string prefix,
            int?maxResults,
            ResultContinuation continuationToken,
            Action <ResultSegment <string> > setResult)
        {
            ResultPagination pagination = new ResultPagination(maxResults.GetValueOrDefault());

            return(this.ListTablesSegmentedImplCore(prefix, continuationToken, pagination, null, setResult));
        }
Example #4
0
 /// <summary>
 /// Asserts the type of the continuation.
 /// </summary>
 /// <param name="continuationToken">The continuation token.</param>
 /// <param name="continuationType">Type of the continuation.</param>
 internal static void AssertContinuationType(ResultContinuation continuationToken, ResultContinuation.ContinuationType continuationType)
 {
     if (continuationToken != null)
     {
         if (!(continuationToken.Type == ResultContinuation.ContinuationType.None || continuationToken.Type == continuationType))
         {
             string errorMessage = string.Format(CultureInfo.CurrentCulture, SR.InvalidContinuationType, continuationToken.Type, continuationType);
             throw new InvalidOperationException(errorMessage);
         }
     }
 }
 /// <summary>
 /// Begins an asynchronous operation to return a result segment containing a collection
 /// of table names beginning with the specified prefix.
 /// </summary>
 /// <param name="prefix">The table name prefix.</param>
 /// <param name="maxResults">A non-negative integer value that indicates the maximum number of results to be returned at a time, up to the
 /// per-operation limit of 5000. If this value is zero, the maximum possible number of results will be returned, up to 5000.</param>
 /// <param name="continuationToken">A continuation token returned by a previous listing operation.</param>
 /// <param name="callback">The callback delegate that will receive notification when the asynchronous operation completes.</param>
 /// <param name="state">A user-defined object that will be passed to the callback delegate.</param>
 /// <returns>An <see cref="IAsyncResult"/> that references the asynchronous operation.</returns>
 public IAsyncResult BeginListTablesSegmented(string prefix, int maxResults, ResultContinuation continuationToken, AsyncCallback callback, object state)
 {
     return(TaskImplHelper.BeginImplWithRetry <ResultSegment <string> >(
                (setResult) => this.ListTablesSegmentedImpl(
                    prefix,
                    maxResults,
                    continuationToken,
                    setResult),
                this.RetryPolicy,
                callback,
                state));
 }
Example #6
0
        /// <summary>
        /// Lists the queues impl core.
        /// </summary>
        /// <param name="prefix">The prefix.</param>
        /// <param name="detailsIncluded">The details included.</param>
        /// <param name="continuationToken">The continuation token.</param>
        /// <param name="pagination">The pagination.</param>
        /// <param name="setResult">The set result.</param>
        /// <returns>A <see cref="TaskSequence"/> for listing the queues.</returns>
        private TaskSequence ListQueuesImplCore(
            string prefix,
            QueueListingDetails detailsIncluded,
            ResultContinuation continuationToken,
            ResultPagination pagination,
            Action <ResultSegment <CloudQueue> > setResult)
        {
            CommonUtils.AssertContinuationType(continuationToken, ResultContinuation.ContinuationType.Queue);

            ListingContext listingContext = new ListingContext(prefix, pagination.GetNextRequestPageSize())
            {
                Marker = continuationToken != null ? continuationToken.NextMarker : null
            };

            var queueList = new List <CloudQueue>();

            var webRequest = QueueRequest.List(this.BaseUri, this.Timeout.RoundUpToSeconds(), listingContext, detailsIncluded);

            this.Credentials.SignRequest(webRequest);

            var listTask = webRequest.GetResponseAsyncWithTimeout(this, this.Timeout);

            yield return(listTask);

            string nextMarker;

            using (var response = listTask.Result as HttpWebResponse)
            {
                var parsedResponse = QueueResponse.List(response);

                // Materialize the results so that we can close the response
                queueList.AddRange(parsedResponse.Queues.Select((Func <QueueEntry, CloudQueue>) this.SelectResponse));

                nextMarker = parsedResponse.NextMarker;
            }

            ResultContinuation newContinuationToken = new ResultContinuation()
            {
                NextMarker = nextMarker, Type = ResultContinuation.ContinuationType.Queue
            };

            ResultSegment.CreateResultSegment(
                setResult,
                queueList,
                newContinuationToken,
                pagination,
                this.RetryPolicy,
                (paginationArg, continuationArg, resultSegment) =>
                this.ListQueuesImplCore(prefix, detailsIncluded, continuationArg, paginationArg, resultSegment));
        }
Example #7
0
        /// <summary>
        /// Lists the queues impl.
        /// </summary>
        /// <param name="prefix">The prefix.</param>
        /// <param name="detailsIncluded">The details included.</param>
        /// <param name="continuationToken">The continuation token.</param>
        /// <param name="maxResults">The max results.</param>
        /// <param name="setResult">The set result.</param>
        /// <returns>A <see cref="TaskSequence"/> for listing the queues.</returns>
        private TaskSequence ListQueuesImpl(
            string prefix,
            QueueListingDetails detailsIncluded,
            ResultContinuation continuationToken,
            int?maxResults,
            Action <ResultSegment <CloudQueue> > setResult)
        {
            ResultPagination pagination = new ResultPagination(maxResults.GetValueOrDefault());

            return(this.ListQueuesImplCore(
                       prefix,
                       detailsIncluded,
                       continuationToken,
                       pagination,
                       setResult));
        }
        /// <summary>
        /// Executes the segmented impl.
        /// </summary>
        /// <param name="continuationToken">The continuation token.</param>
        /// <param name="setResult">The set result.</param>
        /// <returns>A <see cref="TaskSequence"/> that executes the query and returns the first segment of results.</returns>
        internal TaskSequence ExecuteSegmentedImpl(ResultContinuation continuationToken, Action <ResultSegment <TElement> > setResult)
        {
            var localQuery = this.query;

            localQuery = RewriteQueryForTakeCount(localQuery, this.pagination);

            localQuery = ApplyContinuationToQuery(continuationToken, localQuery);

            var requestTask = localQuery.ExecuteAsync();

            yield return(requestTask);

            try
            {
                var responseResult = requestTask.Result;
                var response       = responseResult as QueryOperationResponse;

                ResultContinuation newContinuationToken = this.GetTableContinuationFromResponse(response);

                List <TElement> listResult = new List <TElement>(responseResult.ToList());

                ResultSegment.CreateResultSegment <TElement>(
                    setResult,
                    listResult,
                    newContinuationToken,
                    this.pagination,
                    this.RetryPolicy,
                    (scratch, continuationArg, setResultInnerArg) => this.ExecuteSegmentedImpl(continuationArg, setResultInnerArg));
            }
            catch (InvalidOperationException ex)
            {
                var dsce = CommonUtils.FindInnerDataServiceClientException(ex);

                if (dsce == null)
                {
                    throw;
                }

                if ((HttpStatusCode)dsce.StatusCode == HttpStatusCode.NotFound)
                {
                    setResult(new ResultSegment <TElement>(new List <TElement>(), false, null, null));
                }

                throw;
            }
        }
        /// <summary>
        /// Serializes the token.
        /// </summary>
        /// <param name="serializer">The serializer.</param>
        /// <param name="token">The token.</param>
        /// <returns>System.String.</returns>
        public static string SerializeToken(XmlSerializer serializer, ResultContinuation token)
        {
            if (token == null)
            {
                return null;
            }

            using (var writer = new StringWriter())
            {
                var writerSettings = new XmlWriterSettings { OmitXmlDeclaration = true, NewLineChars = String.Empty };

                using (var xmlWriter = XmlWriter.Create(writer, writerSettings))
                {
                    serializer.Serialize(xmlWriter, token);
                }

                return writer.ToString();
            }
        }
        /// <summary>
        /// Gets the table continuation from response.
        /// </summary>
        /// <param name="response">The response.</param>
        /// <returns>The continuation.</returns>
        private ResultContinuation GetTableContinuationFromResponse(QueryOperationResponse response)
        {
            string nextPartitionKey;
            string nextRowKey;
            string nextTableName;

            response.Headers.TryGetValue(TableServicePrefixForTableContinuation + TableServiceNextPartitionKey, out nextPartitionKey);
            response.Headers.TryGetValue(TableServicePrefixForTableContinuation + TableServiceNextRowKey, out nextRowKey);
            response.Headers.TryGetValue(TableServicePrefixForTableContinuation + TableServiceNextTableName, out nextTableName);

            ResultContinuation newContinuationToken = new ResultContinuation()
            {
                NextPartitionKey = nextPartitionKey,
                NextRowKey       = nextRowKey,
                NextTableName    = nextTableName,
                Type             = ResultContinuation.ContinuationType.Table
            };

            return(newContinuationToken);
        }
        /// <summary>
        /// Applies the continuation to query.
        /// </summary>
        /// <param name="continuationToken">The continuation token.</param>
        /// <param name="localQuery">The local query.</param>
        /// <returns>The modified query.</returns>
        private static DataServiceQuery <TElement> ApplyContinuationToQuery(ResultContinuation continuationToken, DataServiceQuery <TElement> localQuery)
        {
            if (continuationToken != null)
            {
                if (continuationToken.NextPartitionKey != null)
                {
                    localQuery = localQuery.AddQueryOption(TableServiceNextPartitionKey, continuationToken.NextPartitionKey);
                }

                if (continuationToken.NextRowKey != null)
                {
                    localQuery = localQuery.AddQueryOption(TableServiceNextRowKey, continuationToken.NextRowKey);
                }

                if (continuationToken.NextTableName != null)
                {
                    localQuery = localQuery.AddQueryOption(TableServiceNextTableName, continuationToken.NextTableName);
                }
            }

            return(localQuery);
        }
Example #12
0
        /// <summary>
        /// Core implementation for the ListContainers method.
        /// </summary>
        /// <param name="prefix">The container prefix.</param>
        /// <param name="detailsIncluded">The details included.</param>
        /// <param name="continuationToken">The continuation token.</param>
        /// <param name="pagination">The pagination.</param>
        /// <param name="setResult">The result report delegate.</param>
        /// <returns>A <see cref="TaskSequence"/> that lists the containers.</returns>
        private TaskSequence ListContainersImplCore(
            string prefix,
            ContainerListingDetails detailsIncluded,
            ResultContinuation continuationToken,
            ResultPagination pagination,
            Action<ResultSegment<CloudBlobContainer>> setResult)
        {
            CommonUtils.AssertContinuationType(continuationToken, ResultContinuation.ContinuationType.Container);

            ListingContext listingContext = new ListingContext(prefix, pagination.GetNextRequestPageSize())
            {
                Marker = continuationToken != null ? continuationToken.NextMarker : null
            };

            var containersList = new List<CloudBlobContainer>();

            var request = ContainerRequest.List(this.BaseUri, this.Timeout.RoundUpToSeconds(), listingContext, detailsIncluded);

            this.Credentials.SignRequest(request);

            var listTask = request.GetResponseAsyncWithTimeout(this, this.Timeout);

            yield return listTask;

            string nextMarker;

            using (var response = listTask.Result as HttpWebResponse)
            {
                ListContainersResponse listContainersResponse = ContainerResponse.List(response);

                containersList.AddRange(listContainersResponse.Containers.Select((item) => new CloudBlobContainer(item.Attributes, this)));

                nextMarker = listContainersResponse.NextMarker;
            }

            ResultContinuation newContinuationToken = new ResultContinuation() { NextMarker = nextMarker, Type = ResultContinuation.ContinuationType.Container };

            ResultSegment.CreateResultSegment(
                setResult,
                containersList,
                newContinuationToken,
                pagination,
                this.RetryPolicy,
                (paginationArg, continuationArg, resultSegmentArg) =>
                    this.ListContainersImplCore(
                        prefix,
                        detailsIncluded,
                        continuationArg,
                        paginationArg,
                        resultSegmentArg));
        }
Example #13
0
        /// <summary>
        /// Implementation for the ListContainers method.
        /// </summary>
        /// <param name="prefix">The container prefix.</param>
        /// <param name="detailsIncluded">The details included.</param>
        /// <param name="continuationToken">The continuation token.</param>
        /// <param name="maxResults">The maximum results to return.</param>
        /// <param name="setResult">The result report delegate.</param>
        /// <returns>A <see cref="TaskSequence"/> that lists the containers.</returns>
        private TaskSequence ListContainersImpl(
            string prefix,
            ContainerListingDetails detailsIncluded,
            ResultContinuation continuationToken,
            int? maxResults,
            Action<ResultSegment<CloudBlobContainer>> setResult)
        {
            ResultPagination pagination = new ResultPagination(maxResults.GetValueOrDefault());

            return this.ListContainersImplCore(prefix, detailsIncluded, continuationToken, pagination, setResult);
        }
        /// <summary>
        /// Begins an asynchronous request to return a result segment containing a collection of blob items.
        /// </summary>
        /// <param name="maxResults">A non-negative integer value that indicates the maximum number of results to be returned at a time, up to the
        /// per-operation limit of 5000. If this value is zero, the maximum possible number of results will be returned, up to 5000.</param>
        /// <param name="continuationToken">A continuation token returned by a previous listing operation.</param>
        /// <param name="options">An object that specifies any additional options for the request.</param>
        /// <param name="callback">The callback delegate that will receive notification when the asynchronous operation completes.</param>
        /// <param name="state">A user-defined object that will be passed to the callback delegate.</param>
        /// <returns>An <see cref="IAsyncResult"/> that references the asynchronous operation.</returns>
        public IAsyncResult BeginListBlobsSegmented(int maxResults, ResultContinuation continuationToken, BlobRequestOptions options, AsyncCallback callback, object state)
        {
            var fullModifiers = BlobRequestOptions.CreateFullModifier(this.ServiceClient, options);

            return(TaskImplHelper.BeginImplWithRetry <ResultSegment <IListBlobItem> >((setResult) => this.Container.ListBlobsImpl(this.Prefix, fullModifiers, continuationToken, maxResults, setResult), fullModifiers.RetryPolicy, callback, state));
        }
 /// <summary>
 /// Returns a result segment containing a collection of table names beginning with the specified prefix.
 /// </summary>
 /// <param name="prefix">The table name prefix.</param>
 /// <param name="maxResults">A non-negative integer value that indicates the maximum number of results to be returned at a time, up to the
 /// per-operation limit of 5000. If this value is zero, the maximum possible number of results will be returned, up to 5000.</param>
 /// <param name="continuationToken">A continuation token returned by a previous listing operation.</param>
 /// <returns>A result segment containing table names.</returns>
 public ResultSegment <string> ListTablesSegmented(string prefix, int maxResults, ResultContinuation continuationToken)
 {
     return(this.EndListTablesSegmented(
                this.BeginListTablesSegmented(prefix, maxResults, continuationToken, null, null)));
 }
        /// <summary>
        /// Implementation for the ListBlobs method.
        /// </summary>
        /// <param name="prefix">The blob prefix.</param>
        /// <param name="options">An object that specifies any additional options for the request.</param>
        /// <param name="continuationToken">The continuation token.</param>
        /// <param name="maxResults">The maximum result size.</param>
        /// <param name="setResult">The result report delegate.</param>
        /// <returns>A <see cref="TaskSequence"/> that lists the blobs.</returns>
        internal TaskSequence ListBlobsImpl(
            string prefix,
            BlobRequestOptions options,
            ResultContinuation continuationToken,
            int? maxResults,
            Action<ResultSegment<IListBlobItem>> setResult)
        {
            ResultPagination pagination = new ResultPagination(maxResults.GetValueOrDefault());

            return this.ListBlobsImplCore(prefix, options, continuationToken, pagination, setResult);
        }
        /// <summary>
        /// Begins an asynchronous operation to return a result segment containing a collection of blob items 
        /// in the container.
        /// </summary>
        /// <param name="maxResults">A non-negative integer value that indicates the maximum number of results to be returned at a time, up to the 
        /// per-operation limit of 5000. If this value is zero, the maximum possible number of results will be returned, up to 5000.</param>         
        /// <param name="continuationToken">A continuation token returned by a previous listing operation.</param> 
        /// <param name="options">An object that specifies any additional options for the request.</param>
        /// <param name="callback">The callback delegate that will receive notification when the asynchronous operation completes.</param>
        /// <param name="state">A user-defined object that will be passed to the callback delegate.</param>
        /// <returns>An <see cref="IAsyncResult"/> that references the asynchronous operation.</returns>
        public IAsyncResult BeginListBlobsSegmented(
            int maxResults,
            ResultContinuation continuationToken,
            BlobRequestOptions options,
            AsyncCallback callback,
            object state)
        {
            var fullModifiers = BlobRequestOptions.CreateFullModifier(this.ServiceClient, options);

            return TaskImplHelper.BeginImplWithRetry<ResultSegment<IListBlobItem>>(
                (setResult) => this.ListBlobsImpl(null, fullModifiers, continuationToken, maxResults, setResult),
                fullModifiers.RetryPolicy,
                callback,
                state);
        }
Example #18
0
 public IAsyncResult BeginListTablesSegmented(string prefix, int maxResults, ResultContinuation continuationToken, AsyncCallback callback, object state);
        /// <summary>
        /// Lists the queues impl core.
        /// </summary>
        /// <param name="prefix">The prefix.</param>
        /// <param name="detailsIncluded">The details included.</param>
        /// <param name="continuationToken">The continuation token.</param>
        /// <param name="pagination">The pagination.</param>
        /// <param name="setResult">The set result.</param>
        /// <returns>A <see cref="TaskSequence"/> for listing the queues.</returns>
        private TaskSequence ListQueuesImplCore(
            string prefix,
            QueueListingDetails detailsIncluded,
            ResultContinuation continuationToken,
            ResultPagination pagination,
            Action<ResultSegment<CloudQueue>> setResult)
        {
            CommonUtils.AssertContinuationType(continuationToken, ResultContinuation.ContinuationType.Queue);

            ListingContext listingContext = new ListingContext(prefix, pagination.GetNextRequestPageSize())
            {
                Marker = continuationToken != null ? continuationToken.NextMarker : null
            };

            var queueList = new List<CloudQueue>();

            var webRequest = QueueRequest.List(this.BaseUri, this.Timeout.RoundUpToSeconds(), listingContext, detailsIncluded);
            this.Credentials.SignRequest(webRequest);

            var listTask = webRequest.GetResponseAsyncWithTimeout(this, this.Timeout);
            yield return listTask;

            string nextMarker;

            using (var response = listTask.Result as HttpWebResponse)
            {
                var parsedResponse = QueueResponse.List(response);

                // Materialize the results so that we can close the response
                queueList.AddRange(parsedResponse.Queues.Select((Func<QueueEntry, CloudQueue>)this.SelectResponse));

                nextMarker = parsedResponse.NextMarker;
            }

            ResultContinuation newContinuationToken = new ResultContinuation() { NextMarker = nextMarker, Type = ResultContinuation.ContinuationType.Queue };

            ResultSegment.CreateResultSegment(
                setResult,
                queueList,
                newContinuationToken,
                pagination,
                this.RetryPolicy,
                (paginationArg, continuationArg, resultSegment) =>
                    this.ListQueuesImplCore(prefix, detailsIncluded, continuationArg, paginationArg, resultSegment));
        }
Example #20
0
 public static ResultSegment<IListBlobItem> ListBlobxWithPrefixSegmented(this CloudBlobContainer container,
                                                                       string prefix, int maxresults, ResultContinuation continuationToken, BlobRequestOptions options = null)
 {
     string searchRoot = container.Name + "/" + prefix;
     if (options != null)
         return CurrBlobClient.ListBlobsWithPrefixSegmented(searchRoot, maxresults, continuationToken, options);
     return CurrBlobClient.ListBlobsWithPrefixSegmented(searchRoot, maxresults, continuationToken);
 }
Example #21
0
        /// <summary>
        /// Implementation for the ListBlobs method.
        /// </summary>
        /// <param name="prefix">The blob prefix.</param>
        /// <param name="continuationToken">The continuation token.</param>
        /// <param name="maxResults">The max results.</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 lists the blobs.
        /// </returns>
        private TaskSequence ListBlobImpl(
            string prefix,
            ResultContinuation continuationToken,
            int? maxResults,
            BlobRequestOptions options,
            Action<ResultSegment<IListBlobItem>> setResult)
        {
            CommonUtils.AssertContinuationType(continuationToken, ResultContinuation.ContinuationType.Blob);

            string containerName = null;
            string listingPrefix = null;

            ParseUserPrefix(prefix, out containerName, out listingPrefix);
            var containerInfo = new CloudBlobContainer(containerName, this);

            var fullModifier = BlobRequestOptions.CreateFullModifier(this, options);

            return containerInfo.ListBlobsImpl(listingPrefix, fullModifier, continuationToken, maxResults, setResult);
        }
        /// <summary>
        /// Core implementation of the ListBlobs method.
        /// </summary>
        /// <param name="prefix">The blob prefix.</param>
        /// <param name="options">An object that specifies any additional options for the request.</param>
        /// <param name="continuationToken">The continuation token.</param>
        /// <param name="pagination">The pagination.</param>
        /// <param name="setResult">The result report delegate.</param>
        /// <returns>A <see cref="TaskSequence"/> that lists the blobs.</returns>
        private TaskSequence ListBlobsImplCore(
            string prefix,
            BlobRequestOptions options,
            ResultContinuation continuationToken,
            ResultPagination pagination,
            Action<ResultSegment<IListBlobItem>> setResult)
        {
            CommonUtils.AssertContinuationType(continuationToken, ResultContinuation.ContinuationType.Blob);
            CommonUtils.AssertNotNull("options", options);

            if (!options.UseFlatBlobListing
                && (options.BlobListingDetails & BlobListingDetails.Snapshots) == BlobListingDetails.Snapshots)
            {
                throw new ArgumentException(SR.ListSnapshotsWithDelimiterError, "options");
            }

            var delimiter = options.UseFlatBlobListing ? null : this.ServiceClient.DefaultDelimiter;

            BlobListingContext listingContext = new BlobListingContext(prefix, pagination.GetNextRequestPageSize(), delimiter, options.BlobListingDetails)
            {
                Marker = continuationToken != null ? continuationToken.NextMarker : null
            };

            var blobList = new List<IListBlobItem>();

            var request = ProtocolHelper.GetWebRequest(this.ServiceClient, options, (timeout) => BlobRequest.List(this.TransformedAddress, timeout, listingContext));
            this.ServiceClient.Credentials.SignRequest(request);
            var listTask = request.GetResponseAsyncWithTimeout(this.ServiceClient, options.Timeout);
            yield return listTask;

            string nextMarker;
            using (var response = listTask.Result as HttpWebResponse)
            {
                ListBlobsResponse listBlobResponse = BlobResponse.List(response);
                blobList.AddRange(listBlobResponse.Blobs.Select(
                    (item) => CloudBlobClient.SelectProtocolResponse(item, this.ServiceClient, this)));

                nextMarker = listBlobResponse.NextMarker;
            }

            ResultContinuation newContinuationToken = new ResultContinuation() { NextMarker = nextMarker, Type = ResultContinuation.ContinuationType.Blob };

            ResultSegment.CreateResultSegment(
                setResult,
                blobList,
                newContinuationToken,
                pagination,
                options.RetryPolicy,
                (paginationArg, continuationArg, resultSegmentArg) =>
                    this.ListBlobsImplCore(prefix, options, continuationArg, paginationArg, resultSegmentArg));
        }
Example #23
0
 /// <summary>
 /// Returns a result segment containing a collection of containers
 /// whose names begin with the specified prefix.
 /// </summary>
 /// <param name="prefix">The container name prefix.</param>
 /// <param name="detailsIncluded">A value that indicates whether to return container metadata with the listing.</param>
 /// <param name="maxResults">A non-negative integer value that indicates the maximum number of results to be returned 
 /// in the result segment, up to the per-operation limit of 5000. If this value is zero, the maximum possible number of results will be returned, up to 5000.</param>         
 /// <param name="continuationToken">A continuation token returned by a previous listing operation.</param> 
 /// <returns>A result segment of containers.</returns>
 public ResultSegment<CloudBlobContainer> ListContainersSegmented(
     string prefix,
     ContainerListingDetails detailsIncluded,
     int maxResults,
     ResultContinuation continuationToken)
 {
     return TaskImplHelper.ExecuteImplWithRetry<ResultSegment<CloudBlobContainer>>(
         (setResult) => this.ListContainersImpl(prefix, detailsIncluded, continuationToken, maxResults, setResult),
         this.RetryPolicy);
 }
        /// <summary>
        /// Returns a result segment containing a collection of blob items 
        /// in the container.
        /// </summary>
        /// <param name="maxResults">A non-negative integer value that indicates the maximum number of results to be returned at a time, up to the 
        /// per-operation limit of 5000. If this value is zero, the maximum possible number of results will be returned, up to 5000.</param>         
        /// <param name="continuationToken">A continuation token returned by a previous listing operation.</param> 
        /// <param name="options">An object that specifies any additional options for the request.</param>
        /// <returns>A result segment containing objects that implement <see cref="IListBlobItem"/>.</returns>
        public ResultSegment<IListBlobItem> ListBlobsSegmented(int maxResults, ResultContinuation continuationToken, BlobRequestOptions options)
        {
            var fullModifiers = BlobRequestOptions.CreateFullModifier(this.ServiceClient, options);

            return TaskImplHelper.ExecuteImplWithRetry<ResultSegment<IListBlobItem>>(
                (setResult) => this.ListBlobsImpl(null, fullModifiers, continuationToken, maxResults, setResult),
                fullModifiers.RetryPolicy);
        }
Example #25
0
 /// <summary>
 /// Returns a result segment containing a collection of queues
 /// whose names begin with the specified prefix.
 /// </summary>
 /// <param name="prefix">The queue name prefix.</param>
 /// <param name="detailsIncluded">One of the enumeration values that indicates which details to include in the listing.</param>
 /// <param name="maxResults">A non-negative integer value that indicates the maximum number of results to be returned at a time, up to the
 /// per-operation limit of 5000. If this value is zero, the maximum possible number of results will be returned, up to 5000.</param>
 /// <param name="continuationToken">A continuation token returned by a previous listing operation.</param>
 /// <returns>A result segment containing a collection of queues.</returns>
 public ResultSegment <CloudQueue> ListQueuesSegmented(string prefix, QueueListingDetails detailsIncluded, int maxResults, ResultContinuation continuationToken)
 {
     return(TaskImplHelper.ExecuteImplWithRetry <ResultSegment <CloudQueue> >(
                (setResult) => this.ListQueuesImpl(prefix, detailsIncluded, continuationToken, maxResults, setResult),
                this.RetryPolicy));
 }
 /// <summary>
 /// Returns a result segment containing a collection of table names in the storage account.
 /// </summary>
 /// <param name="maxResults">A non-negative integer value that indicates the maximum number of results to be returned at a time, up to the
 /// per-operation limit of 5000. If this value is zero, the maximum possible number of results will be returned, up to 5000.</param>
 /// <param name="continuationToken">A continuation token returned by a previous listing operation.</param>
 /// <returns>A result segment containing table names.</returns>
 public ResultSegment <string> ListTablesSegmented(int maxResults, ResultContinuation continuationToken)
 {
     return(this.ListTablesSegmented(String.Empty, maxResults, continuationToken));
 }
        /// <summary>
        /// Returns a result segment containing a collection of blob items.
        /// </summary>
        /// <param name="maxResults">A non-negative integer value that indicates the maximum number of results to be returned at a time, up to the
        /// per-operation limit of 5000. If this value is zero, the maximum possible number of results will be returned, up to 5000.</param>
        /// <param name="continuationToken">A continuation token returned by a previous listing operation.</param>
        /// <param name="options">An object that specifies any additional options for the request.</param>
        /// <returns>A result segment containing objects that implement <see cref="IListBlobItem"/>.</returns>
        public ResultSegment <IListBlobItem> ListBlobsSegmented(int maxResults, ResultContinuation continuationToken, BlobRequestOptions options)
        {
            var fullModifiers = BlobRequestOptions.CreateFullModifier(this.ServiceClient, options);

            return(TaskImplHelper.ExecuteImplWithRetry <ResultSegment <IListBlobItem> >((setResult) => this.Container.ListBlobsImpl(this.Prefix, fullModifiers, continuationToken, maxResults, setResult), fullModifiers.RetryPolicy));
        }
Example #28
0
 public ResultSegment<string> ListTablesSegmented(string prefix, int maxResults, ResultContinuation continuationToken);
Example #29
0
 /// <summary>
 /// Begins an asynchronous operation to return a result segment containing a collection 
 /// of blob items whose names begin with the specified prefix.
 /// </summary>
 /// <param name="prefix">The blob name prefix. This value must be preceded either by the name of the container or by the absolute path to the container.</param>
 /// <param name="maxResults">A non-negative integer value that indicates the maximum number of results to be returned at a time, up to the 
 /// per-operation limit of 5000. If this value is zero, the maximum possible number of results will be returned, up to 5000.</param>         
 /// <param name="continuationToken">A continuation token returned by a previous listing operation.</param> 
 /// <param name="callback">The callback delegate that will receive notification when the asynchronous operation completes.</param>
 /// <param name="state">A user-defined object that will be passed to the callback delegate.</param>
 /// <returns>An <see cref="IAsyncResult"/> that references the asynchronous operation.</returns>
 public IAsyncResult BeginListBlobsWithPrefixSegmented(
     string prefix,
     int maxResults,
     ResultContinuation continuationToken,
     AsyncCallback callback,
     object state)
 {
     return TaskImplHelper.BeginImplWithRetry<ResultSegment<IListBlobItem>>(
         (setResult) => this.ListBlobImpl(prefix, continuationToken, maxResults, null, setResult),
         this.RetryPolicy,
         callback,
         state);
 }
Example #30
0
 /// <summary>
 /// Begins an asynchronous request to return a result segment containing a collection of containers
 /// whose names begin with the specified prefix.
 /// </summary>
 /// <param name="prefix">The container name prefix.</param>
 /// <param name="detailsIncluded">A value that indicates whether to return container metadata with the listing.</param>
 /// <param name="maxResults">A non-negative integer value that indicates the maximum number of results to be returned 
 /// in the result segment, up to the per-operation limit of 5000. If this value is zero, the maximum possible number of results will be returned, up to 5000.</param>         
 /// <param name="continuationToken">A continuation token returned by a previous listing operation.</param> 
 /// <param name="callback">The callback delegate that will receive notification when the asynchronous operation completes.</param>
 /// <param name="state">A user-defined object that will be passed to the callback delegate.</param>
 /// <returns>An <see cref="IAsyncResult"/> that references the asynchronous operation.</returns>
 public IAsyncResult BeginListContainersSegmented(
     string prefix,
     ContainerListingDetails detailsIncluded,
     int maxResults,
     ResultContinuation continuationToken,
     AsyncCallback callback,
     object state)
 {
     return TaskImplHelper.BeginImplWithRetry<ResultSegment<CloudBlobContainer>>(
         (setResult) => this.ListContainersImpl(prefix, detailsIncluded, continuationToken, maxResults, setResult),
         this.RetryPolicy,
         callback,
         state);
 }
 /// <summary>
 /// Executes the query with the retry policy specified on the <see cref="CloudTableQuery&lt;TElement&gt;"/> object.
 /// </summary>
 /// <param name="continuationToken">A continuation token returned by a previous listing operation.</param>
 /// <returns>The results of the query, retrieved lazily.</returns>
 public IEnumerable <TElement> Execute(ResultContinuation continuationToken)
 {
     return(CommonUtils.LazyEnumerateSegmented <TElement>(
                (setResult) => this.ExecuteSegmentedImpl(continuationToken, setResult),
                this.RetryPolicy));
 }
Example #32
0
 /// <summary>
 /// Begins an asynchronous operation to return a result segment containing a collection of queues
 /// whose names begin with the specified prefix.
 /// </summary>
 /// <param name="prefix">The queue name prefix.</param>
 /// <param name="detailsIncluded">One of the enumeration values that indicates which details to include in the listing.</param>
 /// <param name="maxResults">A non-negative integer value that indicates the maximum number of results to be returned at a time, up to the
 /// per-operation limit of 5000. If this value is zero, the maximum possible number of results will be returned, up to 5000.</param>
 /// <param name="continuationToken">A continuation token returned by a previous listing operation.</param>
 /// <param name="callback">The callback delegate that will receive notification when the asynchronous operation completes.</param>
 /// <param name="state">A user-defined object that will be passed to the callback delegate.</param>
 /// <returns>An <see cref="IAsyncResult"/> that references the asynchronous operation.</returns>
 public IAsyncResult BeginListQueuesSegmented(string prefix, QueueListingDetails detailsIncluded, int maxResults, ResultContinuation continuationToken, AsyncCallback callback, object state)
 {
     return(TaskImplHelper.BeginImplWithRetry <ResultSegment <CloudQueue> >(
                (setResult) => this.ListQueuesImpl(prefix, detailsIncluded, continuationToken, maxResults, setResult),
                this.RetryPolicy,
                callback,
                state));
 }
Example #33
0
 /// <summary>
 /// Returns a result segment containing a collection of blob items whose names
 /// begin with the specified prefix.
 /// </summary>
 /// <param name="prefix">The blob name prefix. This value must be preceded either by the name of the container or by the absolute path to the container.</param>
 /// <param name="maxResults">A non-negative integer value that indicates the maximum number of results to be returned at a time, up to the per-operation limit of 5000. 
 /// If this value is zero, the maximum possible number of results will be returned, up to 5000.</param>         
 /// <param name="continuationToken">A continuation token returned by a previous listing operation.</param> 
 /// <returns>A result segment containing objects that implement <see cref="IListBlobItem"/>.</returns>
 public ResultSegment<IListBlobItem> ListBlobsWithPrefixSegmented(
     string prefix,
     int maxResults,
     ResultContinuation continuationToken)
 {
     return this.ListBlobsWithPrefixSegmented(prefix, maxResults, continuationToken, null);
 }
Example #34
0
        /// <summary>
        /// Returns a result segment containing a collection of blob items whose names
        /// begin with the specified prefix.
        /// </summary>
        /// <param name="prefix">The blob name prefix. This value must be preceded either by the name of the container or by the absolute path to the container.</param>
        /// <param name="maxResults">A non-negative integer value that indicates the maximum number of results to be returned at a time, up to the per-operation limit of 5000. 
        /// If this value is zero, the maximum possible number of results will be returned, up to 5000.</param>         
        /// <param name="continuationToken">A continuation token returned by a previous listing operation.</param> 
        /// <param name="options">An object that specifies any additional options for the request.</param>
        /// <returns>A result segment containing objects that implement <see cref="IListBlobItem"/>.</returns>
        public ResultSegment<IListBlobItem> ListBlobsWithPrefixSegmented(
            string prefix,
            int maxResults,
            ResultContinuation continuationToken,
            BlobRequestOptions options)
        {
            var fullModifier = BlobRequestOptions.CreateFullModifier(this, options);

            return TaskImplHelper.ExecuteImplWithRetry<ResultSegment<IListBlobItem>>(
               (setResult) => this.ListBlobImpl(prefix, continuationToken, maxResults, fullModifier, setResult),
               this.RetryPolicy);
        }
 /// <summary>Returns a result segment containing a collection of queues whose names begin with the specified prefix.</summary>
 /// <param name="prefix">The queue name prefix. </param>
 /// <param name="detailsIncluded">One of the enumeration values that indicates which details to include in the listing. </param>
 /// <param name="maxResults">A non-negative integer value that indicates the maximum number of results to be returned at a time, up to the per-operation limit of 5000. If this value is zero, the maximum possible number of results will be returned, up to 5000. </param>
 /// <param name="continuationToken">A continuation token returned by a previous listing operation. </param>
 /// <returns>A result segment containing a collection of queues. </returns>
 public ResultSegment<CloudQueue> ListQueuesSegmented(
     string prefix, QueueListingDetails detailsIncluded, int maxResults, ResultContinuation continuationToken)
 {
     return
         TaskImplHelper.ExecuteImplWithRetry<ResultSegment<CloudQueue>>(
             setResult =>
             this.ListQueuesImpl(prefix, detailsIncluded, continuationToken, maxResults, setResult),
             this.RetryPolicy);
 }