Esempio n. 1
0
        public ShareResultSegment ListSharesSegmented(string prefix, ShareListingDetails detailsIncluded, int?maxResults, FileContinuationToken currentToken, FileRequestOptions options = null, OperationContext operationContext = null)
        {
            FileRequestOptions             modifiedOptions = FileRequestOptions.ApplyDefaults(options, this);
            ResultSegment <CloudFileShare> resultSegment   = this.ListSharesSegmentedCore(prefix, detailsIncluded, maxResults, currentToken, modifiedOptions, operationContext);

            return(new ShareResultSegment(resultSegment.Results, (FileContinuationToken)resultSegment.ContinuationToken));
        }
Esempio n. 2
0
        public IEnumerable <CloudFileShare> ListShares(string prefix = null, ShareListingDetails detailsIncluded = ShareListingDetails.None, FileRequestOptions options = null, OperationContext operationContext = null)
        {
            FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this);

            return(CommonUtility.LazyEnumerable(
                       token => this.ListSharesSegmentedCore(prefix, detailsIncluded, null, (FileContinuationToken)token, modifiedOptions, operationContext),
                       long.MaxValue));
        }
Esempio n. 3
0
        public ICancellableAsyncResult BeginListSharesSegmented(string prefix, ShareListingDetails detailsIncluded, int?maxResults, FileContinuationToken currentToken, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state)
        {
            FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this);

            return(Executor.BeginExecuteAsync(
                       this.ListSharesImpl(prefix, detailsIncluded, currentToken, maxResults, modifiedOptions),
                       modifiedOptions.RetryPolicy,
                       operationContext,
                       callback,
                       state));
        }
        public Task EnumerateSharesAsync(string prefix, ShareListingDetails detailsIncluded, Action <CloudFileShare> enumerationAction, FileRequestOptions options, OperationContext operationContext, CancellationToken token)
        {
            foreach (var shareName in this.availableShareNames)
            {
                if (shareName.StartsWith(prefix))
                {
                    enumerationAction(this.client.GetShareReference(shareName));
                }
            }

            return(TaskEx.FromResult(true));
        }
Esempio n. 5
0
        public void CloudFileClientListSharesSegmentedPrefixDetailsIncludedMaxResultsContinuationTokenOptionsOperationContextCancellationTokenTask()
        {
            int             shareCount      = 3;
            string          shareNamePrefix = GetRandomShareName();
            List <string>   shareNames      = new List <string>(shareCount);
            CloudFileClient fileClient      = GenerateCloudFileClient();

            string prefix = shareNamePrefix;
            ShareListingDetails detailsIncluded = ShareListingDetails.None;
            int?maxResults = 10;
            FileContinuationToken continuationToken = null;
            FileRequestOptions    options           = new FileRequestOptions();
            OperationContext      operationContext  = new OperationContext();
            CancellationToken     cancellationToken = CancellationToken.None;

            try
            {
                for (int i = 0; i < shareCount; ++i)
                {
                    string shareName = shareNamePrefix + i.ToString();
                    shareNames.Add(shareName);
                    fileClient.GetShareReference(shareName).CreateAsync().Wait();
                }

                int totalCount = 0;
                do
                {
                    ShareResultSegment resultSegment = fileClient.ListSharesSegmentedAsync(prefix, detailsIncluded, maxResults, continuationToken, options, operationContext, cancellationToken).Result;
                    continuationToken = resultSegment.ContinuationToken;

                    int count = 0;
                    foreach (CloudFileShare share in resultSegment.Results)
                    {
                        if (shareNames.Contains(share.Name))
                        {
                            ++totalCount;
                        }
                        ++count;
                    }

                    Assert.IsTrue(count <= maxResults.Value);
                }while (continuationToken != null);

                Assert.AreEqual(shareCount, totalCount);
            }
            finally
            {
                foreach (string shareName in shareNames)
                {
                    fileClient.GetShareReference(shareName).DeleteAsync().Wait();
                }
            }
        }
        public Task <ShareResultSegment> ListSharesSegmentedAsync(string prefix, ShareListingDetails detailsIncluded, int?maxResults, FileContinuationToken currentToken, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
        {
            return(Task.Run(async() =>
            {
                FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this);
                ResultSegment <CloudFileShare> resultSegment = await Executor.ExecuteAsync(
                    this.ListSharesImpl(prefix, detailsIncluded, currentToken, maxResults, modifiedOptions),
                    modifiedOptions.RetryPolicy,
                    operationContext,
                    cancellationToken);

                return new ShareResultSegment(resultSegment.Results, (FileContinuationToken)resultSegment.ContinuationToken);
            }, cancellationToken));
        }
Esempio n. 7
0
        public async Task EnumerateSharesAsync(string prefix, ShareListingDetails detailsIncluded, Action <CloudFileShare> enumerationAction, FileRequestOptions options, OperationContext operationContext, CancellationToken token)
        {
            FileContinuationToken continuationToken = null;

            do
            {
                var segment = await this.Client.ListSharesSegmentedAsync(prefix, detailsIncluded, null, continuationToken, options, operationContext, token);

                foreach (var item in segment.Results)
                {
                    enumerationAction(item);
                }

                continuationToken = segment.ContinuationToken;
            }while (continuationToken != null);
        }
Esempio n. 8
0
        /// <summary>
        /// Constructs a web request to return a listing of all shares in this storage account.
        /// </summary>
        /// <param name="uri">The absolute URI for the account.</param>
        /// <param name="timeout">The server timeout interval.</param>
        /// <param name="listingContext">A set of parameters for the listing operation.</param>
        /// <param name="detailsIncluded">Additional details to return with the listing.</param>
        /// <param name="useVersionHeader">A boolean value indicating whether to set the <i>x-ms-version</i> HTTP header.</param>
        /// <param name="operationContext">An <see cref="OperationContext" /> object for tracking the current operation.</param>
        /// <returns>A web request for the specified operation.</returns>
        public static HttpWebRequest List(Uri uri, int?timeout, ListingContext listingContext, ShareListingDetails detailsIncluded, bool useVersionHeader, OperationContext operationContext)
        {
            UriQueryBuilder builder = new UriQueryBuilder();

            builder.Add(Constants.QueryConstants.Component, "list");

            if (listingContext != null)
            {
                if (listingContext.Prefix != null)
                {
                    builder.Add("prefix", listingContext.Prefix);
                }

                if (listingContext.Marker != null)
                {
                    builder.Add("marker", listingContext.Marker);
                }

                if (listingContext.MaxResults.HasValue)
                {
                    builder.Add("maxresults", listingContext.MaxResults.ToString());
                }
            }

            if ((detailsIncluded & ShareListingDetails.Metadata) != 0)
            {
                builder.Add("include", "metadata");
            }

            HttpWebRequest request = HttpWebRequestFactory.CreateWebRequest(WebRequestMethods.Http.Get, uri, timeout, builder, useVersionHeader, operationContext);

            return(request);
        }
Esempio n. 9
0
        /// <summary>
        /// Core implementation for the ListShares method.
        /// </summary>
        /// <param name="prefix">The share prefix.</param>
        /// <param name="detailsIncluded">The details included.</param>
        /// <param name="currentToken">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 shares.</returns>
        private RESTCommand <ResultSegment <CloudFileShare> > ListSharesImpl(string prefix, ShareListingDetails detailsIncluded, FileContinuationToken currentToken, int?maxResults, FileRequestOptions options)
        {
            ListingContext listingContext = new ListingContext(prefix, maxResults)
            {
                Marker = currentToken != null ? currentToken.NextMarker : null
            };

            RESTCommand <ResultSegment <CloudFileShare> > getCmd = new RESTCommand <ResultSegment <CloudFileShare> >(this.Credentials, this.StorageUri);

            options.ApplyToStorageCommand(getCmd);
            getCmd.CommandLocationMode    = CommonUtility.GetListingLocationMode(currentToken);
            getCmd.RetrieveResponseStream = true;
            getCmd.Handler             = this.AuthenticationHandler;
            getCmd.BuildClient         = HttpClientFactory.BuildHttpClient;
            getCmd.BuildRequest        = (cmd, uri, builder, cnt, serverTimeout, ctx) => ShareHttpRequestMessageFactory.List(uri, serverTimeout, listingContext, detailsIncluded, cnt, ctx);
            getCmd.PreProcessResponse  = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null, cmd, ex);
            getCmd.PostProcessResponse = (cmd, resp, ctx) =>
            {
                return(Task.Factory.StartNew(() =>
                {
                    ListSharesResponse listSharesResponse = new ListSharesResponse(cmd.ResponseStream);
                    List <CloudFileShare> sharesList = listSharesResponse.Shares.Select(item => new CloudFileShare(item.Properties, item.Metadata, item.Name, this)).ToList();
                    FileContinuationToken continuationToken = null;
                    if (listSharesResponse.NextMarker != null)
                    {
                        continuationToken = new FileContinuationToken()
                        {
                            NextMarker = listSharesResponse.NextMarker,
                            TargetLocation = cmd.CurrentResult.TargetLocation,
                        };
                    }

                    return new ResultSegment <CloudFileShare>(sharesList)
                    {
                        ContinuationToken = continuationToken,
                    };
                }));
            };

            return(getCmd);
        }
Esempio n. 10
0
 public virtual Task <ShareResultSegment> ListSharesSegmentedAsync(string prefix, ShareListingDetails detailsIncluded, int?maxResults, FileContinuationToken currentToken, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
 {
     throw new System.NotImplementedException();
 }
        /// <summary>
        /// Constructs a web request to return a listing of all shares in this storage account.
        /// </summary>
        /// <param name="uri">The absolute URI for the account.</param>
        /// <param name="timeout">The server timeout interval.</param>
        /// <param name="listingContext">A set of parameters for the listing operation.</param>
        /// <param name="detailsIncluded">Additional details to return with the listing.</param>
        /// <returns>A web request for the specified operation.</returns>
        public static StorageRequestMessage List(Uri uri, int?timeout, ListingContext listingContext, ShareListingDetails detailsIncluded, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials)
        {
            UriQueryBuilder builder = new UriQueryBuilder();

            builder.Add(Constants.QueryConstants.Component, "list");

            if (listingContext != null)
            {
                if (listingContext.Prefix != null)
                {
                    builder.Add("prefix", listingContext.Prefix);
                }

                if (listingContext.Marker != null)
                {
                    builder.Add("marker", listingContext.Marker);
                }

                if (listingContext.MaxResults.HasValue)
                {
                    builder.Add("maxresults", listingContext.MaxResults.ToString());
                }
            }

            if (detailsIncluded != ShareListingDetails.None)
            {
                StringBuilder sb      = new StringBuilder();
                bool          started = false;

                if ((detailsIncluded & ShareListingDetails.Metadata) == ShareListingDetails.Metadata)
                {
                    if (!started)
                    {
                        started = true;
                    }
                    else
                    {
                        sb.Append(",");
                    }

                    sb.Append("metadata");
                }

                builder.Add("include", sb.ToString());
            }

            StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Get, uri, timeout, builder, content, operationContext, canonicalizer, credentials);

            return(request);
        }
Esempio n. 12
0
        public Task<ShareResultSegment> ListSharesSegmentedAsync(string prefix, ShareListingDetails detailsIncluded, int? maxResults, FileContinuationToken currentToken, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
        {
            return Task.Run(async () =>
            {
                FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this);
                ResultSegment<CloudFileShare> resultSegment = await Executor.ExecuteAsync(
                    this.ListSharesImpl(prefix, detailsIncluded, currentToken, maxResults, modifiedOptions),
                    modifiedOptions.RetryPolicy,
                    operationContext,
                    cancellationToken);

                return new ShareResultSegment(resultSegment.Results, (FileContinuationToken)resultSegment.ContinuationToken);
            }, cancellationToken);
        }
Esempio n. 13
0
        /// <summary>
        /// Core implementation for the ListShares method.
        /// </summary>
        /// <param name="prefix">The share prefix.</param>
        /// <param name="detailsIncluded">The details included.</param>
        /// <param name="currentToken">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 shares.</returns>
        private RESTCommand<ResultSegment<CloudFileShare>> ListSharesImpl(string prefix, ShareListingDetails detailsIncluded, FileContinuationToken currentToken, int? maxResults, FileRequestOptions options)
        {
            ListingContext listingContext = new ListingContext(prefix, maxResults)
            {
                Marker = currentToken != null ? currentToken.NextMarker : null
            };

            RESTCommand<ResultSegment<CloudFileShare>> getCmd = new RESTCommand<ResultSegment<CloudFileShare>>(this.Credentials, this.StorageUri);

            options.ApplyToStorageCommand(getCmd);
            getCmd.CommandLocationMode = CommonUtility.GetListingLocationMode(currentToken);
            getCmd.RetrieveResponseStream = true;
            getCmd.Handler = this.AuthenticationHandler;
            getCmd.BuildClient = HttpClientFactory.BuildHttpClient;
            getCmd.BuildRequest = (cmd, uri, builder, cnt, serverTimeout, ctx) => ShareHttpRequestMessageFactory.List(uri, serverTimeout, listingContext, detailsIncluded, cnt, ctx);
            getCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp, null, cmd, ex);
            getCmd.PostProcessResponse = (cmd, resp, ctx) =>
            {
                return Task.Factory.StartNew(() =>
                    {
                        ListSharesResponse listSharesResponse = new ListSharesResponse(cmd.ResponseStream);
                        List<CloudFileShare> sharesList = listSharesResponse.Shares.Select(item => new CloudFileShare(item.Properties, item.Metadata, item.Name, this)).ToList();
                        FileContinuationToken continuationToken = null;
                        if (listSharesResponse.NextMarker != null)
                        {
                            continuationToken = new FileContinuationToken()
                            {
                                NextMarker = listSharesResponse.NextMarker,
                                TargetLocation = cmd.CurrentResult.TargetLocation,
                            };
                        }

                        return new ResultSegment<CloudFileShare>(sharesList)
                        {
                            ContinuationToken = continuationToken,
                        };
                    });
            };

            return getCmd;
        }
Esempio n. 14
0
 private RESTCommand <ResultSegment <CloudFileShare> > ListSharesImpl(string prefix, ShareListingDetails detailsIncluded, FileContinuationToken currentToken, int?maxResults, FileRequestOptions options)
 {
     throw new System.NotImplementedException();
 }
        /// <summary>
        /// Returns an enumerable collection of FileShare.
        /// </summary>
        /// <param name="prefix">The share name prefix.</param>
        /// <param name="detailsIncluded">A value that indicates whether to return share metadata with the listing.</param>
        /// <returns>List of FileShare.</returns>
        public List <FileStorage> ListShares(string prefix = null, ShareListingDetails detailsIncluded = ShareListingDetails.None)
        {
            var shares = this._cloudFileClient.ListShares(prefix, detailsIncluded);

            return(shares.Select(i => new FileStorage(i)).ToList());
        }
Esempio n. 16
0
 public Task <ShareResultSegment> ListSharesSegmentedAsync(string prefix, ShareListingDetails detailsIncluded, int?maxResults, FileContinuationToken currentToken, FileRequestOptions options, OperationContext operationContext)
 {
     return(this.ListSharesSegmentedAsync(prefix, detailsIncluded, maxResults, currentToken, options, operationContext, CancellationToken.None));
 }
Esempio n. 17
0
 /// <summary>
 /// Returns a result segment containing a collection of shares
 /// whose names begin with the specified prefix.
 /// </summary>
 /// <param name="prefix">The share name prefix.</param>
 /// <param name="detailsIncluded">A value that indicates whether to return share 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 null, the maximum possible number of results will be returned, up to 5000.</param>
 /// <param name="currentToken">A continuation token returned by a previous listing operation.</param>
 /// <param name="options">A <see cref="FileRequestOptions"/> 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 shares.</returns>
 private ResultSegment <CloudFileShare> ListSharesSegmentedCore(string prefix, ShareListingDetails detailsIncluded, int?maxResults, FileContinuationToken currentToken, FileRequestOptions options, OperationContext operationContext)
 {
     return(Executor.ExecuteSync(
                this.ListSharesImpl(prefix, detailsIncluded, currentToken, maxResults, options),
                options.RetryPolicy,
                operationContext));
 }
 public virtual ICancellableAsyncResult BeginListSharesSegmented(string prefix, ShareListingDetails detailsIncluded, int? maxResults, FileContinuationToken currentToken, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state)
 {
     FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this);
     return Executor.BeginExecuteAsync(
         this.ListSharesImpl(prefix, detailsIncluded, currentToken, maxResults, modifiedOptions),
         modifiedOptions.RetryPolicy, 
         operationContext, 
         callback, 
         state);
 }
 /// <summary>
 /// Returns a result segment containing a collection of shares
 /// whose names begin with the specified prefix.
 /// </summary>
 /// <param name="prefix">The share name prefix.</param>
 /// <param name="detailsIncluded">A value that indicates whether to return share 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 null, the maximum possible number of results will be returned, up to 5000.</param>         
 /// <param name="currentToken">A continuation token returned by a previous listing operation.</param> 
 /// <param name="options">A <see cref="FileRequestOptions"/> 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 shares.</returns>
 private ResultSegment<CloudFileShare> ListSharesSegmentedCore(string prefix, ShareListingDetails detailsIncluded, int? maxResults, FileContinuationToken currentToken, FileRequestOptions options, OperationContext operationContext)
 {
     return Executor.ExecuteSync(
         this.ListSharesImpl(prefix, detailsIncluded, currentToken, maxResults, options),
         options.RetryPolicy, 
         operationContext);
 }
 public virtual ShareResultSegment ListSharesSegmented(string prefix, ShareListingDetails detailsIncluded, int? maxResults, FileContinuationToken currentToken, FileRequestOptions options = null, OperationContext operationContext = null)
 {
     FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this);
     ResultSegment<CloudFileShare> resultSegment = this.ListSharesSegmentedCore(prefix, detailsIncluded, maxResults, currentToken, modifiedOptions, operationContext);
     return new ShareResultSegment(resultSegment.Results, (FileContinuationToken)resultSegment.ContinuationToken);
 }
 public virtual IEnumerable<CloudFileShare> ListShares(string prefix = null, ShareListingDetails detailsIncluded = ShareListingDetails.None, FileRequestOptions options = null, OperationContext operationContext = null)
 {
     FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this);
     return CommonUtility.LazyEnumerable(
         token => this.ListSharesSegmentedCore(prefix, detailsIncluded, null, (FileContinuationToken)token, modifiedOptions, operationContext),
         long.MaxValue);
 }
Esempio n. 22
0
        /// <summary>
        /// Constructs a web request to return a listing of all shares in this storage account.
        /// </summary>
        /// <param name="uri">The absolute URI for the account.</param>
        /// <param name="timeout">The server timeout interval.</param>
        /// <param name="listingContext">A set of parameters for the listing operation.</param>
        /// <param name="detailsIncluded">Additional details to return with the listing.</param>
        /// <param name="useVersionHeader">A boolean value indicating whether to set the <i>x-ms-version</i> HTTP header.</param>
        /// <param name="operationContext">An <see cref="OperationContext" /> object for tracking the current operation.</param>
        /// <returns>A web request for the specified operation.</returns>
        public static HttpWebRequest List(Uri uri, int?timeout, ListingContext listingContext, ShareListingDetails detailsIncluded, bool useVersionHeader, OperationContext operationContext)
        {
            UriQueryBuilder builder = new UriQueryBuilder();

            builder.Add(Constants.QueryConstants.Component, "list");

            if (listingContext != null)
            {
                if (listingContext.Prefix != null)
                {
                    builder.Add("prefix", listingContext.Prefix);
                }

                if (listingContext.Marker != null)
                {
                    builder.Add("marker", listingContext.Marker);
                }

                if (listingContext.MaxResults.HasValue)
                {
                    builder.Add("maxresults", listingContext.MaxResults.ToString());
                }
            }

            if (detailsIncluded != ShareListingDetails.None)
            {
                StringBuilder sb      = new StringBuilder();
                bool          started = false;

                if ((detailsIncluded & ShareListingDetails.Metadata) == ShareListingDetails.Metadata)
                {
                    if (!started)
                    {
                        started = true;
                    }
                    else
                    {
                        sb.Append(",");
                    }

                    sb.Append("metadata");
                }

                //TODO: Enable with ShareSnapshot
                //if ((detailsIncluded & ShareListingDetails.Snapshots) == ShareListingDetails.Snapshots)
                //{
                //    if (!started)
                //    {
                //        started = true;
                //    }
                //    else
                //    {
                //        sb.Append(",");
                //    }

                //    sb.Append("snapshots");
                //}

                builder.Add("include", sb.ToString());
            }

            HttpWebRequest request = HttpWebRequestFactory.CreateWebRequest(WebRequestMethods.Http.Get, uri, timeout, builder, useVersionHeader, operationContext);

            return(request);
        }
 public virtual Task<ShareResultSegment> ListSharesSegmentedAsync(string prefix, ShareListingDetails detailsIncluded, int? maxResults, FileContinuationToken currentToken, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
 {
     return AsyncExtensions.TaskFromApm(this.BeginListSharesSegmented, this.EndListSharesSegmented, prefix, detailsIncluded, maxResults, currentToken, options, operationContext, cancellationToken);
 }
        /// <summary>
        /// Constructs a web request to return a listing of all shares in this storage account.
        /// </summary>
        /// <param name="uri">The absolute URI for the account.</param>
        /// <param name="timeout">The server timeout interval.</param>
        /// <param name="listingContext">A set of parameters for the listing operation.</param>
        /// <param name="detailsIncluded">Additional details to return with the listing.</param>
        /// <returns>A web request for the specified operation.</returns>
        public static HttpRequestMessage List(Uri uri, int? timeout, ListingContext listingContext, ShareListingDetails detailsIncluded, HttpContent content, OperationContext operationContext)
        {
            UriQueryBuilder builder = new UriQueryBuilder();
            builder.Add(Constants.QueryConstants.Component, "list");

            if (listingContext != null)
            {
                if (listingContext.Prefix != null)
                {
                    builder.Add("prefix", listingContext.Prefix);
                }

                if (listingContext.Marker != null)
                {
                    builder.Add("marker", listingContext.Marker);
                }

                if (listingContext.MaxResults.HasValue)
                {
                    builder.Add("maxresults", listingContext.MaxResults.ToString());
                }
            }

            if ((detailsIncluded & ShareListingDetails.Metadata) != 0)
            {
                builder.Add("include", "metadata");
            }

            HttpRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Get, uri, timeout, builder, content, operationContext);
            return request;
        }
Esempio n. 25
0
 public Task <ShareResultSegment> ListSharesSegmentedAsync(string prefix, ShareListingDetails detailsIncluded, int?maxResults, FileContinuationToken currentToken, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
 {
     return(AsyncExtensions.TaskFromApm(this.BeginListSharesSegmented, this.EndListSharesSegmented, prefix, detailsIncluded, maxResults, currentToken, options, operationContext, cancellationToken));
 }
        public virtual ICancellableAsyncResult BeginListSharesSegmented(string prefix, ShareListingDetails detailsIncluded, int?maxResults, FileContinuationToken currentToken, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state)
        {
            FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this);

            return(CancellableAsyncResultTaskWrapper.Create(token => this.ListSharesSegmentedAsync(prefix, detailsIncluded, maxResults, currentToken, modifiedOptions, operationContext), callback, state));
        }
        public Task EnumerateSharesAsync(string prefix, ShareListingDetails detailsIncluded, Action<CloudFileShare> enumerationAction, FileRequestOptions options, OperationContext operationContext, CancellationToken token)
        {
            foreach (var shareName in this.availableShareNames)
            {
                if (shareName.StartsWith(prefix))
                {
                    enumerationAction(this.client.GetShareReference(shareName));
                }
            }

            return TaskEx.FromResult(true);
        }
Esempio n. 28
0
 public Task<ShareResultSegment> ListSharesSegmentedAsync(string prefix, ShareListingDetails detailsIncluded, int? maxResults, FileContinuationToken currentToken, FileRequestOptions options, OperationContext operationContext)
 {
     return this.ListSharesSegmentedAsync(prefix, detailsIncluded, maxResults, currentToken, options, operationContext, CancellationToken.None);
 }
        public async Task EnumerateSharesAsync(string prefix, ShareListingDetails detailsIncluded, Action<CloudFileShare> enumerationAction, FileRequestOptions options, OperationContext operationContext, CancellationToken token)
        {
            FileContinuationToken continuationToken = null;
            do
            {
                var segment = await this.Client.ListSharesSegmentedAsync(prefix, detailsIncluded, null, continuationToken, options, operationContext, token);
                foreach (var item in segment.Results)
                {
                    enumerationAction(item);
                }

                continuationToken = segment.ContinuationToken;
            }
            while (continuationToken != null);
        }
Esempio n. 30
0
 /// <summary>
 /// Returns an enumerable collection of FileShare.
 /// </summary>
 /// <param name="prefix">The share name prefix.</param>
 /// <param name="detailsIncluded">A value that indicates whether to return share metadata with the listing.</param>
 /// <param name="cancellationToken">A <see cref="T:System.Threading.CancellationToken" /> to observe while waiting for a task to complete.</param>
 /// <returns>List of FileShare.</returns>
 public Task <List <FileStorage> > ListSharesAsync(string prefix = null, ShareListingDetails detailsIncluded = ShareListingDetails.None, CancellationToken?cancellationToken = null)
 {
     return(Task.Run(
                () => this._cloudFileClient.ListShares(prefix, detailsIncluded).Select(i => new FileStorage(i)).ToList(),
                cancellationToken ?? CancellationToken.None));
 }