public Task<QueueResultSegment> ListQueuesSegmentedAsync(string prefix, QueueContinuationToken currentToken) { return this.ListQueuesSegmentedAsync(prefix, currentToken, CancellationToken.None); }
/// <summary> /// Begins an asynchronous operation to return a result segment containing a collection of queue items. /// </summary> /// <param name="prefix">The queue name prefix.</param> /// <param name="currentToken">A <see cref="QueueContinuationToken"/> 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="ICancellableAsyncResult"/> that references the asynchronous operation.</returns> public ICancellableAsyncResult BeginListQueuesSegmented(string prefix, QueueContinuationToken currentToken, AsyncCallback callback, object state) { return this.BeginListQueuesSegmented(prefix, QueueListingDetails.None, null, currentToken, null, null, callback, state); }
/// <summary> /// Begins an asynchronous operation to return a result segment containing a collection of queue items. /// </summary> /// <param name="prefix">The queue name prefix.</param> /// <param name="queueListingDetails">A <see cref="QueueListingDetails"/> enumeration describing which items 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 <c>null</c>, the maximum possible number of results will be returned, up to 5000.</param> /// <param name="currentToken">A <see cref="QueueContinuationToken"/> returned by a previous listing operation.</param> /// <param name="options">An object that specifies additional options for the request.</param> /// <param name="operationContext">An <see cref="OperationContext"/> object that represents the context for the current operation. This object is used to track requests, and to provide additional runtime information about the 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="ICancellableAsyncResult"/> that references the asynchronous operation.</returns> public ICancellableAsyncResult BeginListQueuesSegmented(string prefix, QueueListingDetails queueListingDetails, int? maxResults, QueueContinuationToken currentToken, QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this); operationContext = operationContext ?? new OperationContext(); return Executor.BeginExecuteAsync( this.ListQueuesImpl(prefix, maxResults, queueListingDetails, modifiedOptions, currentToken), modifiedOptions.RetryPolicy, operationContext, callback, state); }
/// <summary> /// Returns a result segment containing a collection of queues. /// </summary> /// <param name="currentToken">A <see cref="QueueContinuationToken"/> token returned by a previous listing operation.</param> /// <returns>A result segment of queues.</returns> public IAsyncOperation<QueueResultSegment> ListQueuesSegmentedAsync(QueueContinuationToken currentToken) { return this.ListQueuesSegmentedAsync(null, QueueListingDetails.None, 0, currentToken, null); }
/// <summary> /// Returns a result segment containing a collection of queues. /// </summary> /// <param name="currentToken">A <see cref="QueueContinuationToken"/> token returned by a previous listing operation.</param> /// <returns>A result segment of queues.</returns> #if ASPNET_K || PORTABLE public Task<QueueResultSegment> ListQueuesSegmentedAsync(QueueContinuationToken currentToken)
public Task<QueueResultSegment> ListQueuesSegmentedAsync(string prefix, QueueListingDetails queueListingDetails, int? maxResults, QueueContinuationToken currentToken, QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginListQueuesSegmented, this.EndListQueuesSegmented, prefix, queueListingDetails, maxResults, currentToken, options, operationContext, cancellationToken); }
internal QueueResultSegment(IEnumerable<CloudQueue> queues, QueueContinuationToken continuationToken) { this.Results = queues; this.ContinuationToken = continuationToken; }
/// <summary> /// Returns a result segment containing a collection of queues. /// </summary> /// <param name="currentToken">A <see cref="QueueContinuationToken"/> continuation token returned by a previous listing operation.</param> /// <returns>A <see cref="QueueResultSegment"/> object.</returns> public virtual QueueResultSegment ListQueuesSegmented(QueueContinuationToken currentToken) { return this.ListQueuesSegmented(null, QueueListingDetails.None, null, currentToken, null, null); }
public virtual Task<QueueResultSegment> ListQueuesSegmentedAsync(QueueContinuationToken currentToken) { return this.ListQueuesSegmentedAsync(currentToken, CancellationToken.None); }
public void QueueContinuationTokenVerifySerializer() { XmlSerializer serializer = new XmlSerializer(typeof(QueueContinuationToken)); XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; StringReader reader; string tokenxml; QueueContinuationToken writeToken = new QueueContinuationToken { NextMarker = Guid.NewGuid().ToString(), TargetLocation = StorageLocation.Primary }; QueueContinuationToken readToken = null; // Write with XmlSerializer using (StringWriter writer = new StringWriter()) { serializer.Serialize(writer, writeToken); tokenxml = writer.ToString(); } // Read with XmlSerializer reader = new StringReader(tokenxml); readToken = (QueueContinuationToken)serializer.Deserialize(reader); Assert.AreEqual(writeToken.NextMarker, readToken.NextMarker); // Read with token.ReadXml() using (XmlReader xmlReader = XmlReader.Create(new StringReader(tokenxml))) { readToken = new QueueContinuationToken(); readToken.ReadXml(xmlReader); } Assert.AreEqual(writeToken.NextMarker, readToken.NextMarker); // Read with token.ReadXml() using (XmlReader xmlReader = XmlReader.Create(new StringReader(tokenxml))) { readToken = new QueueContinuationToken(); readToken.ReadXml(xmlReader); } // Write with token.WriteXml StringBuilder sb = new StringBuilder(); using (XmlWriter writer = XmlWriter.Create(sb, settings)) { writeToken.WriteXml(writer); } // Read with XmlSerializer reader = new StringReader(sb.ToString()); readToken = (QueueContinuationToken)serializer.Deserialize(reader); Assert.AreEqual(writeToken.NextMarker, readToken.NextMarker); // Read with token.ReadXml() using (XmlReader xmlReader = XmlReader.Create(new StringReader(sb.ToString()))) { readToken = new QueueContinuationToken(); readToken.ReadXml(xmlReader); } Assert.AreEqual(writeToken.NextMarker, readToken.NextMarker); }
public void QueueContinuationTokenVerifyXmlWithinXml() { CloudQueueClient client = GenerateCloudQueueClient(); string prefix = "dotnetqueuetest" + Guid.NewGuid().ToString("N"); List<string> queueNames = new List<string>(); int count = 30; for (int i = 0; i < count; i++) { queueNames.Add(prefix + i); client.GetQueueReference(prefix + i).Create(); } QueueContinuationToken token = null; List<CloudQueue> results = new List<CloudQueue>(); do { QueueResultSegment segment = client.ListQueuesSegmented(prefix, QueueListingDetails.None, 5, token, null, null); token = segment.ContinuationToken; results.AddRange(segment.Results); if (token != null) { Assert.AreEqual(null, token.GetSchema()); XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; StringBuilder sb = new StringBuilder(); using (XmlWriter writer = XmlWriter.Create(sb, settings)) { writer.WriteStartElement("test1"); writer.WriteStartElement("test2"); token.WriteXml(writer); writer.WriteEndElement(); writer.WriteEndElement(); } using (XmlReader reader = XmlReader.Create(new StringReader(sb.ToString()))) { token = new QueueContinuationToken(); reader.ReadStartElement(); reader.ReadStartElement(); token.ReadXml(reader); reader.ReadEndElement(); reader.ReadEndElement(); } } } while (token != null); foreach (CloudQueue queue in results) { if (queueNames.Remove(queue.Name)) { queue.Delete(); } else { Assert.Fail(); } } Assert.AreEqual<int>(0, queueNames.Count); }
public virtual Task<QueueResultSegment> ListQueuesSegmentedAsync(string prefix, QueueContinuationToken currentToken) { return this.ListQueuesSegmentedAsync(prefix, QueueListingDetails.None, null, currentToken, null, null); }
/// <summary> /// Core implementation for the ListQueues method. /// </summary> /// <param name="prefix">The queue prefix.</param> /// <param name="detailsIncluded">The details included.</param> /// <param name="currentToken">The continuation token.</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 <c>null</c>, the maximum possible number of results will be returned, up to 5000.</param> /// <returns>A <see cref="TaskSequence"/> that lists the queues.</returns> private RESTCommand<ResultSegment<CloudQueue>> ListQueuesImpl(string prefix, int? maxResults, QueueListingDetails detailsIncluded, QueueRequestOptions options, QueueContinuationToken currentToken) { ListingContext listingContext = new ListingContext(prefix, maxResults) { Marker = currentToken != null ? currentToken.NextMarker : null }; RESTCommand<ResultSegment<CloudQueue>> getCmd = new RESTCommand<ResultSegment<CloudQueue>>(this.Credentials, this.StorageUri); options.ApplyToStorageCommand(getCmd); getCmd.CommandLocationMode = CommonUtility.GetListingLocationMode(currentToken); getCmd.RetrieveResponseStream = true; getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => QueueHttpRequestMessageFactory.List(uri, serverTimeout, listingContext, detailsIncluded, cnt, ctx, this.GetCanonicalizer(), this.Credentials); getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null /* retVal */, cmd, ex); getCmd.PostProcessResponse = (cmd, resp, ctx) => { return Task.Factory.StartNew(() => { ListQueuesResponse listQueuesResponse = new ListQueuesResponse(cmd.ResponseStream); List<CloudQueue> queuesList = listQueuesResponse.Queues.Select(item => new CloudQueue(item.Metadata, item.Name, this)).ToList(); QueueContinuationToken continuationToken = null; if (listQueuesResponse.NextMarker != null) { continuationToken = new QueueContinuationToken() { NextMarker = listQueuesResponse.NextMarker, TargetLocation = cmd.CurrentResult.TargetLocation, }; } return new ResultSegment<CloudQueue>(queuesList) { ContinuationToken = continuationToken, }; }); }; return getCmd; }
public void QueueContinuationTokenVerifyEmptyTargetDeserializer() { QueueContinuationToken queueContinuationToken = new QueueContinuationToken { TargetLocation = null }; StringBuilder stringBuilder = new StringBuilder(); using (XmlWriter writer = XmlWriter.Create(stringBuilder)) { queueContinuationToken.WriteXml(writer); } string stringToken = stringBuilder.ToString(); QueueContinuationToken parsedToken = new QueueContinuationToken(); parsedToken.ReadXml(XmlReader.Create(new System.IO.StringReader(stringToken))); Assert.AreEqual(parsedToken.TargetLocation, null); }
public Task<QueueResultSegment> ListQueuesSegmentedAsync(string prefix, QueueContinuationToken currentToken, CancellationToken cancellationToken) { return AsyncExtensions.TaskFromApm(this.BeginListQueuesSegmented, this.EndListQueuesSegmented, prefix, currentToken, cancellationToken); }
/// <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">A value that indicates whether to return queue 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 <c>null</c>, the maximum possible number of results will be returned, up to 5000.</param> /// <param name="currentToken">A <see cref="QueueContinuationToken"/> token returned by a previous listing operation.</param> /// <param name="options">An object that specifies additional options for the request.</param> /// <param name="operationContext">An <see cref="OperationContext"/> object that represents the context for the current operation.</param> /// <returns>A result segment of queues.</returns> public IAsyncOperation<QueueResultSegment> ListQueuesSegmentedAsync(string prefix, QueueListingDetails detailsIncluded, int? maxResults, QueueContinuationToken currentToken, QueueRequestOptions options, OperationContext operationContext) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this); operationContext = operationContext ?? new OperationContext(); return AsyncInfo.Run(async (token) => { ResultSegment<CloudQueue> resultSegment = await Executor.ExecuteAsync( this.ListQueuesImpl(prefix, maxResults, detailsIncluded, modifiedOptions, currentToken), this.RetryPolicy, operationContext, token); return new QueueResultSegment(resultSegment.Results, (QueueContinuationToken)resultSegment.ContinuationToken); }); }
public Task<QueueResultSegment> ListQueuesSegmentedAsync(string prefix, QueueListingDetails queueListingDetails, int? maxResults, QueueContinuationToken currentToken, QueueRequestOptions options, OperationContext operationContext) { return this.ListQueuesSegmentedAsync(prefix, queueListingDetails, maxResults, currentToken, options, operationContext, CancellationToken.None); }
/// <summary> /// Returns a result segment containing a collection of queues in the storage account. /// </summary> /// <param name="prefix">The queue name prefix.</param> /// <param name="currentToken">A <see cref="QueueContinuationToken"/> continuation token returned by a previous listing operation.</param> /// <returns>A result segment containing objects that implement <see cref="CloudQueue"/>.</returns> public QueueResultSegment ListQueuesSegmented(string prefix, QueueContinuationToken currentToken) { return this.ListQueuesSegmented(prefix, QueueListingDetails.None, null, currentToken, null, null); }
/// <summary> /// Core implementation of the ListQueues method. /// </summary> /// <param name="prefix">The queue 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 <c>null</c>, the maximum possible number of results will be returned, up to 5000.</param> /// <param name="queueListingDetails">A <see cref="QueueListingDetails"/> enumeration describing which items to include in the listing.</param> /// <param name="options">An object that specifies additional options for the request.</param> /// <param name="currentToken">The continuation token.</param> /// <returns>A <see cref="RESTCommand{T}"/> that lists the queues.</returns> private RESTCommand<ResultSegment<CloudQueue>> ListQueuesImpl(string prefix, int? maxResults, QueueListingDetails queueListingDetails, QueueRequestOptions options, QueueContinuationToken currentToken) { QueueListingContext listingContext = new QueueListingContext(prefix, maxResults, queueListingDetails) { Marker = currentToken != null ? currentToken.NextMarker : null }; RESTCommand<ResultSegment<CloudQueue>> getCmd = new RESTCommand<ResultSegment<CloudQueue>>(this.Credentials, this.BaseUri); getCmd.ApplyRequestOptions(options); getCmd.RetrieveResponseStream = true; getCmd.BuildRequestDelegate = (uri, builder, serverTimeout, ctx) => QueueHttpWebRequestFactory.List(uri, serverTimeout, listingContext, queueListingDetails, ctx); getCmd.SignRequest = this.AuthenticationHandler.SignRequest; getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null /* retVal */, cmd, ex); getCmd.PostProcessResponse = (cmd, resp, ctx) => { ListQueuesResponse listQueuesResponse = new ListQueuesResponse(cmd.ResponseStream); List<CloudQueue> queuesList = new List<CloudQueue>( listQueuesResponse.Queues.Select(item => new CloudQueue(item.Name, this))); QueueContinuationToken continuationToken = null; if (listQueuesResponse.NextMarker != null) { continuationToken = new QueueContinuationToken() { NextMarker = listQueuesResponse.NextMarker, }; } return new ResultSegment<CloudQueue>(queuesList) { ContinuationToken = continuationToken, }; }; return getCmd; }
/// <summary> /// Returns a result segment containing a collection of queues in the storage account. /// </summary> /// <param name="prefix">The queue name prefix.</param> /// <param name="queueListingDetails">A <see cref="QueueListingDetails"/> enumeration describing which items 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 <c>null</c>, the maximum possible number of results will be returned, up to 5000.</param> /// <param name="currentToken">A <see cref="QueueContinuationToken"/> returned by a previous listing operation.</param> /// <param name="options">An object that specifies additional options for the request.</param> /// <param name="operationContext">An <see cref="OperationContext"/> object that represents the context for the current operation. This object is used to track requests, and to provide additional runtime information about the operation.</param> /// <returns>A result segment containing objects that implement <see cref="CloudQueue"/>.</returns> public QueueResultSegment ListQueuesSegmented(string prefix, QueueListingDetails queueListingDetails, int? maxResults, QueueContinuationToken currentToken, QueueRequestOptions options = null, OperationContext operationContext = null) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this); operationContext = operationContext ?? new OperationContext(); ResultSegment<CloudQueue> resultSegment = this.ListQueuesSegmentedCore(prefix, queueListingDetails, maxResults, currentToken, modifiedOptions, operationContext); return new QueueResultSegment(resultSegment.Results, (QueueContinuationToken)resultSegment.ContinuationToken); }
/// <summary> /// Core implementation for the ListQueues method. /// </summary> /// <param name="prefix">The queue prefix.</param> /// <param name="detailsIncluded">The details included.</param> /// <param name="currentToken">The continuation token.</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 <c>null</c>, the maximum possible number of results will be returned, up to 5000.</param> /// <returns>A <see cref="TaskSequence"/> that lists the queues.</returns> private RESTCommand<ResultSegment<CloudQueue>> ListQueuesImpl(string prefix, QueueListingDetails detailsIncluded, QueueContinuationToken currentToken, int? maxResults) { ListingContext listingContext = new ListingContext(prefix, maxResults) { Marker = currentToken != null ? currentToken.NextMarker : null }; RESTCommand<ResultSegment<CloudQueue>> getCmd = new RESTCommand<ResultSegment<CloudQueue>>(this.Credentials, this.BaseUri); getCmd.RetrieveResponseStream = true; getCmd.Handler = this.AuthenticationHandler; getCmd.BuildClient = HttpClientFactory.BuildHttpClient; getCmd.BuildRequest = (cmd, cnt, ctx) => QueueHttpRequestMessageFactory.List(cmd.Uri, cmd.ServerTimeoutInSeconds, listingContext, detailsIncluded, cnt, ctx); getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null /* retVal */, cmd, ex, ctx); getCmd.PostProcessResponse = (cmd, resp, ex, ctx) => { return Task.Factory.StartNew(() => { ListQueuesResponse listQueuesResponse = new ListQueuesResponse(cmd.ResponseStream); List<CloudQueue> queuesList = new List<CloudQueue>( listQueuesResponse.Queues.Select(item => new CloudQueue(item.Name, this))); QueueContinuationToken continuationToken = null; if (listQueuesResponse.NextMarker != null) { continuationToken = new QueueContinuationToken() { NextMarker = listQueuesResponse.NextMarker, }; } return new ResultSegment<CloudQueue>(queuesList) { ContinuationToken = continuationToken, }; }); }; return getCmd; }
/// <summary> /// Returns a result segment containing a collection of queues in the storage account. /// </summary> /// <param name="prefix">The queue name prefix.</param> /// <param name="queueListingDetails">A <see cref="QueueListingDetails"/> enumeration describing which items 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 <c>null</c>, the maximum possible number of results will be returned, up to 5000.</param> /// <param name="currentToken">A <see cref="QueueContinuationToken"/> returned by a previous listing operation.</param> /// <param name="options">An object that specifies additional options for the request.</param> /// <param name="operationContext">An <see cref="OperationContext"/> object that represents the context for the current operation. This object is used to track requests, and to provide additional runtime information about the operation.</param> /// <returns>A result segment.</returns> private ResultSegment<CloudQueue> ListQueuesSegmentedCore(string prefix, QueueListingDetails queueListingDetails, int? maxResults, QueueContinuationToken currentToken, QueueRequestOptions options, OperationContext operationContext) { return Executor.ExecuteSync( this.ListQueuesImpl(prefix, maxResults, queueListingDetails, options, currentToken), options.RetryPolicy, operationContext); }
/// <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">A value that indicates whether to return queue 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 <c>null</c>, the maximum possible number of results will be returned, up to 5000.</param> /// <param name="currentToken">A <see cref="QueueContinuationToken"/> token returned by a previous listing operation.</param> /// <param name="operationContext">An <see cref="OperationContext"/> object that represents the context for the current operation.</param> /// <returns>A result segment of queues.</returns> public IAsyncOperation<QueueResultSegment> ListQueuesSegmentedAsync(string prefix, QueueListingDetails detailsIncluded, int? maxResults, QueueContinuationToken currentToken, OperationContext operationContext) { return AsyncInfo.Run(async (token) => { ResultSegment<CloudQueue> resultSegment = await Executor.ExecuteAsync( this.ListQueuesImpl(prefix, detailsIncluded, currentToken, maxResults), this.RetryPolicy, operationContext, token); return new QueueResultSegment(resultSegment.Results, (QueueContinuationToken)resultSegment.ContinuationToken); }); }
public IAsyncOperation<QueueResultSegment> ListQueuesSegmentedAsync(string prefix, QueueContinuationToken currentToken) #endif { return this.ListQueuesSegmentedAsync(prefix, QueueListingDetails.None, null, currentToken, null, null); }