internal QueueResultSegment(IEnumerable <CloudQueue> queues, QueueContinuationToken continuationToken) { this.Results = queues; this.ContinuationToken = continuationToken; }
public virtual Task <QueueResultSegment> ListQueuesSegmentedAsync(string prefix, QueueContinuationToken currentToken) { return(this.ListQueuesSegmentedAsync(prefix, QueueListingDetails.None, null, currentToken, null, null)); }
public virtual Task <QueueResultSegment> ListQueuesSegmentedAsync(string prefix, QueueListingDetails detailsIncluded, int?maxResults, QueueContinuationToken currentToken, QueueRequestOptions options, OperationContext operationContext) { return(this.ListQueuesSegmentedAsync(prefix, detailsIncluded, maxResults, currentToken, options, operationContext, CancellationToken.None)); }
public virtual async Task <QueueResultSegment> ListQueuesSegmentedAsync(string prefix, QueueListingDetails detailsIncluded, int?maxResults, QueueContinuationToken currentToken, QueueRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { QueueRequestOptions modifiedOptions = QueueRequestOptions.ApplyDefaults(options, this); operationContext = operationContext ?? new OperationContext(); ResultSegment <CloudQueue> resultSegment = await Executor.ExecuteAsync( this.ListQueuesImpl(prefix, maxResults, detailsIncluded, modifiedOptions, currentToken), modifiedOptions.RetryPolicy, operationContext, cancellationToken).ConfigureAwait(false); 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, 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, this.HttpClient); 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.PostProcessResponseAsync = async(cmd, resp, ctx, ct) => { ListQueuesResponse listQueuesResponse = await ListQueuesResponse.ParseAsync(cmd.ResponseStream, ct).ConfigureAwait(false); 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 async Task 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 = XMLReaderExtensions.CreateAsAsync(new MemoryStream(Encoding.Unicode.GetBytes(tokenxml)))) { readToken = new QueueContinuationToken(); await readToken.ReadXmlAsync(xmlReader); } Assert.AreEqual(writeToken.NextMarker, readToken.NextMarker); // Read with token.ReadXml() using (XmlReader xmlReader = XMLReaderExtensions.CreateAsAsync(new MemoryStream(Encoding.Unicode.GetBytes(tokenxml)))) { readToken = new QueueContinuationToken(); await readToken.ReadXmlAsync(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 = XMLReaderExtensions.CreateAsAsync(new MemoryStream(Encoding.Unicode.GetBytes(sb.ToString())))) { readToken = new QueueContinuationToken(); await readToken.ReadXmlAsync(xmlReader); } Assert.AreEqual(writeToken.NextMarker, readToken.NextMarker); }
public async Task 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 = XMLReaderExtensions.CreateAsAsync(new MemoryStream(Encoding.Unicode.GetBytes(sb.ToString())))) { token = new QueueContinuationToken(); await reader.ReadStartElementAsync(); await reader.ReadStartElementAsync(); await token.ReadXmlAsync(reader); await reader.ReadEndElementAsync(); await reader.ReadEndElementAsync(); } } }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, CancellationToken cancellationToken) { return(this.ListQueuesSegmentedAsync(prefix, QueueListingDetails.None, maxResults: null, currentToken: currentToken, options: null, operationContext: null, cancellationToken: cancellationToken)); }
/// <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(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 queues. /// </summary> /// <param name="prefix">A string containing 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">A <see cref="QueueRequestOptions"/> 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> /// <param name="callback">An <see cref="AsyncCallback"/> 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 virtual ICancellableAsyncResult BeginListQueuesSegmented(string prefix, QueueListingDetails queueListingDetails, int?maxResults, QueueContinuationToken currentToken, QueueRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state) { return(CancellableAsyncResultTaskWrapper.Create(token => this.ListQueuesSegmentedAsync(prefix, queueListingDetails, maxResults, currentToken, options, operationContext, token), callback, state)); }
/// <summary> /// Begins an asynchronous operation to return a result segment containing a collection of queues. /// </summary> /// <param name="prefix">A string containing the queue name prefix.</param> /// <param name="currentToken">A <see cref="QueueContinuationToken"/> returned by a previous listing operation.</param> /// <param name="callback">An <see cref="AsyncCallback"/> 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 virtual ICancellableAsyncResult BeginListQueuesSegmented(string prefix, QueueContinuationToken currentToken, AsyncCallback callback, object state) { return(this.BeginListQueuesSegmented(prefix, QueueListingDetails.None, null, currentToken, null, null, callback, state)); }
/// <summary> /// Returns a result segment containing a collection of queues. /// </summary> /// <param name="prefix">A string containing 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">A <see cref="QueueRequestOptions"/> 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 <see cref="ResultSegment{T}"/> of type <see cref="CloudQueue"/>.</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. /// </summary> /// <param name="prefix">A string containing 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">A <see cref="QueueRequestOptions"/> object that specifies additional options for the request. If <c>null</c>, default options are applied to the request.</param> /// <param name="operationContext">An <see cref="OperationContext"/> object that represents the context for the current operation.</param> /// <returns>A <see cref="QueueResultSegment"/> object.</returns> public virtual 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)); }