public override void PollCycle()
		{
			#region storage
			var storageAccount = CloudStorageAccount.Parse(AccountConnectionString);
			var queueClient = storageAccount.CreateCloudQueueClient();

			var continuationToken = new QueueContinuationToken();

			while (continuationToken != null)
			{
				var listResponse = queueClient.ListQueuesSegmented(continuationToken);

				// We must ask Azure for the size of each queue individually.
				// This can be done in parallel.
				Parallel.ForEach(listResponse.Results, queue =>
				{
					try
					{
						queue.FetchAttributes();
					}
					catch (Exception e)
					{
						// Failed to communicate with Azure Storage, or queue is gone.
					}

				});

				// ReportMetric is not thread-safe, so we can't call it in the parallel
				foreach (var queue in listResponse.Results)
				{
					int count = queue.ApproximateMessageCount.HasValue ? queue.ApproximateMessageCount.Value : 0;
					string metricName = string.Format("storage/{0}/{1}", AccountName, queue.Name);

					ReportMetric(metricName, "messages", count);
				}

				continuationToken = listResponse.ContinuationToken;
			}
			#endregion
		}
Beispiel #2
0
 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));
 }
        /// <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="blobListingDetails">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 zero, 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 any 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 blobListingDetails, 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, blobListingDetails, modifiedOptions, currentToken),
                       modifiedOptions.RetryPolicy,
                       operationContext,
                       callback,
                       state));
        }
Beispiel #4
0
        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);
        }
 /// <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 any 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));
 }
Beispiel #6
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">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);
            }));
        }
Beispiel #7
0
 /// <summary>
 /// Returns a result segment containing a collection of queues.
 /// </summary>
 /// <param name="prefix">The queue name prefix.</param>
 /// <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(string prefix, QueueContinuationToken currentToken)
 {
     return(this.ListQueuesSegmentedAsync(prefix, QueueListingDetails.None, null, currentToken, null, null));
 }
Beispiel #8
0
 /// <summary>
 /// Returns 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"/> continuation token returned by a previous listing operation.</param>
 /// <returns>A <see cref="QueueResultSegment"/> object.</returns>
 public virtual QueueResultSegment ListQueuesSegmented(string prefix, QueueContinuationToken currentToken)
 {
     return(this.ListQueuesSegmented(prefix, QueueListingDetails.None, null, currentToken, null, null));
 }
Beispiel #9
0
 public virtual Task <QueueResultSegment> ListQueuesSegmentedAsync(string prefix, QueueContinuationToken currentToken)
 {
     return(this.ListQueuesSegmentedAsync(prefix, currentToken, CancellationToken.None));
 }
 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));
 }
        public virtual async Task <QueueResultSegment> ListQueuesSegmentedAsync(string prefix, QueueListingDetails queueListingDetails, 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, queueListingDetails, modifiedOptions, currentToken),
                modifiedOptions.RetryPolicy,
                operationContext,
                cancellationToken).ConfigureAwait(false);

            return(new QueueResultSegment(resultSegment.Results, (QueueContinuationToken)resultSegment.ContinuationToken));
        }
 /// <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));
 }
Beispiel #13
0
 public Task <QueueResultSegment> ListQueuesSegmentedAsync(QueueContinuationToken currentToken)
 {
     return(this.ListQueuesSegmentedAsync(currentToken, CancellationToken.None));
 }
Beispiel #14
0
 /// <summary>
 /// Returns a result segment containing a collection of queues in the storage account.
 /// </summary>
 /// <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(QueueContinuationToken currentToken)
 {
     return(this.ListQueuesSegmented(null, QueueListingDetails.None, null, currentToken, null, null));
 }
 internal QueueResultSegment(IEnumerable <CloudQueue> queues, QueueContinuationToken continuationToken)
 {
     this.Results           = queues;
     this.ContinuationToken = continuationToken;
 }
Beispiel #16
0
 public virtual Task <QueueResultSegment> ListQueuesSegmentedAsync(string prefix, QueueContinuationToken currentToken, CancellationToken cancellationToken)
 {
     return(AsyncExtensions.TaskFromApm(this.BeginListQueuesSegmented, this.EndListQueuesSegmented, prefix, currentToken, cancellationToken));
 }
Beispiel #17
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">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);
            }));
        }
Beispiel #18
0
 public virtual 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));
 }
Beispiel #19
0
        /// <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.BaseUri);

            getCmd.ApplyRequestOptions(options);
            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);
            getCmd.PostProcessResponse = (cmd, resp, 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);
        }
 internal QueueResultSegment(IEnumerable<CloudQueue> queues, QueueContinuationToken continuationToken)
 {
     this.Results = queues;
     this.ContinuationToken = continuationToken;
 }
Beispiel #21
0
        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);
        }
        /// <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)
        /// <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 any 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));
        }
Beispiel #24
0
        /// <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);
        }
 /// <summary>
 /// Begins an asynchronous operation to return a result segment containing a collection of queue items.
 /// </summary>
 /// <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(QueueContinuationToken currentToken, AsyncCallback callback, object state)
 {
     return(this.BeginListQueuesSegmented(null, QueueListingDetails.None, 0, currentToken, null, null, callback, state));
 }
Beispiel #26
0
 public virtual Task <QueueResultSegment> ListQueuesSegmentedAsync(QueueContinuationToken currentToken)
 {
     return(this.ListQueuesSegmentedAsync(null, 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 any 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)
        {
            int?nullableMaxResults             = (maxResults > 0) ? maxResults : null;
            QueueListingContext listingContext = new QueueListingContext(prefix, nullableMaxResults, queueListingDetails)
            {
                Marker = currentToken != null ? currentToken.NextMarker : null
            };

            RESTCommand <ResultSegment <CloudQueue> > getCmd = new RESTCommand <ResultSegment <CloudQueue> >(this.Credentials, this.BaseUri);

            options.ApplyToStorageCommand(getCmd);
            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, ctx);
            getCmd.PostProcessResponse    = (cmd, resp, ex, 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);
        }
Beispiel #28
0
 internal QueueResultSegment(IEnumerable <CloudQueue> queues, QueueContinuationToken continuationToken)
 {
     throw new System.NotImplementedException();
 }