Ejemplo n.º 1
0
        /// <summary>
        /// Gets all existing message queues through a series of synchronous operations,
        /// each of which requests a subset of the available queues.
        /// </summary>
        /// <param name="provider">The queueing service.</param>
        /// <param name="limit">The maximum number of <see cref="CloudQueue"/> to return from a single call to <see cref="QueueingServiceExtensions.ListQueues"/>. If this value is <see langword="null"/>, a provider-specific default is used.</param>
        /// <param name="detailed"><see langword="true"/> to return detailed information for each queue; otherwise, <see langword="false"/>.</param>
        /// <returns>A collection of <see cref="CloudQueue"/> objects describing the available queues.</returns>
        /// <exception cref="ArgumentNullException">If <paramref name="provider"/> is <see langword="null"/>.</exception>
        /// <exception cref="ArgumentOutOfRangeException">If <paramref name="limit"/> is less than or equal to 0.</exception>
        /// <exception cref="WebException">If the REST request does not return successfully.</exception>
        private static ReadOnlyCollection <CloudQueue> ListAllQueues(IQueueingService provider, int?limit, bool detailed)
        {
            if (provider == null)
            {
                throw new ArgumentNullException("provider");
            }
            if (limit <= 0)
            {
                throw new ArgumentOutOfRangeException("limit");
            }

            return(provider.ListQueues(null, limit, detailed).GetAllPages());
        }
        /// <summary>
        /// Gets all existing message queues through a series of synchronous operations,
        /// each of which requests a subset of the available queues.
        /// </summary>
        /// <param name="provider">The queueing service.</param>
        /// <param name="limit">The maximum number of <see cref="CloudQueue"/> to return from a single call to <see cref="QueueingServiceExtensions.ListQueues"/>. If this value is <see langword="null"/>, a provider-specific default is used.</param>
        /// <param name="detailed"><see langword="true"/> to return detailed information for each queue; otherwise, <see langword="false"/>.</param>
        /// <returns>A collection of <see cref="CloudQueue"/> objects describing the available queues.</returns>
        /// <exception cref="ArgumentNullException">If <paramref name="provider"/> is <see langword="null"/>.</exception>
        /// <exception cref="ArgumentOutOfRangeException">If <paramref name="limit"/> is less than or equal to 0.</exception>
        /// <exception cref="WebException">If the REST request does not return successfully.</exception>
        private static ReadOnlyCollection<CloudQueue> ListAllQueues(IQueueingService provider, int? limit, bool detailed)
        {
            if (provider == null)
                throw new ArgumentNullException("provider");
            if (limit <= 0)
                throw new ArgumentOutOfRangeException("limit");

            return provider.ListQueues(null, limit, detailed).GetAllPages();
        }
        /// <summary>
        /// Gets all existing message queues through a series of synchronous operations,
        /// each of which requests a subset of the available queues.
        /// </summary>
        /// <param name="provider">The queueing service.</param>
        /// <param name="limit">The maximum number of <see cref="CloudQueue"/> to return from a single call to <see cref="QueueingServiceExtensions.ListQueues"/>. If this value is <c>null</c>, a provider-specific default is used.</param>
        /// <param name="detailed"><c>true</c> to return detailed information for each queue; otherwise, <c>false</c>.</param>
        /// <returns>A collection of <see cref="CloudQueue"/> objects describing the available queues.</returns>
        private static IEnumerable<CloudQueue> ListAllQueues(IQueueingService provider, int? limit, bool detailed)
        {
            if (limit <= 0)
                throw new ArgumentOutOfRangeException("limit");

            CloudQueue lastQueue = null;

            do
            {
                QueueName marker = lastQueue != null ? lastQueue.Name : null;
                IEnumerable<CloudQueue> queues = provider.ListQueues(marker, limit, detailed);
                lastQueue = null;
                foreach (CloudQueue queue in queues)
                {
                    lastQueue = queue;
                    yield return queue;
                }
            } while (lastQueue != null);
        }