public virtual ICancellableAsyncResult BeginSetServiceProperties(FileServiceProperties properties, FileRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state)
        {
            requestOptions   = FileRequestOptions.ApplyDefaults(requestOptions, this);
            operationContext = operationContext ?? new OperationContext();

            return(CancellableAsyncResultTaskWrapper.Create(token => this.SetServicePropertiesAsync(properties, requestOptions, operationContext), callback, state));
        }
Exemplo n.º 2
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));
        }
Exemplo n.º 3
0
        public virtual Task <bool> CreateIfNotExistsAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
        {
            FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient);

            return(Task.Run(async() =>
            {
                try
                {
                    await Executor.ExecuteAsync(
                        this.CreateDirectoryImpl(modifiedOptions),
                        modifiedOptions.RetryPolicy,
                        operationContext,
                        cancellationToken);

                    return true;
                }
                catch (StorageException e)
                {
                    if ((e.RequestInformation.ExtendedErrorInformation != null) &&
                        (e.RequestInformation.ExtendedErrorInformation.ErrorCode == FileErrorCodeStrings.ResourceAlreadyExists))
                    {
                        return false;
                    }
                    else
                    {
                        throw;
                    }
                }
            }, cancellationToken));
        }
Exemplo n.º 4
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));
        }
Exemplo n.º 5
0
 public FileServiceProperties GetServiceProperties(FileRequestOptions requestOptions = null, OperationContext operationContext = null)
 {
     requestOptions   = FileRequestOptions.ApplyDefaults(requestOptions, this);
     operationContext = operationContext ?? new OperationContext();
     return(Executor.ExecuteSync(
                this.GetServicePropertiesImpl(requestOptions),
                requestOptions.RetryPolicy,
                operationContext));
 }
Exemplo n.º 6
0
 public virtual void SetServiceProperties(FileServiceProperties properties, FileRequestOptions requestOptions = null, OperationContext operationContext = null)
 {
     requestOptions   = FileRequestOptions.ApplyDefaults(requestOptions, this);
     operationContext = operationContext ?? new OperationContext();
     Executor.ExecuteSync(
         this.SetServicePropertiesImpl(properties, requestOptions),
         requestOptions.RetryPolicy,
         operationContext);
 }
Exemplo n.º 7
0
        public IAsyncOperation <bool> DeleteIfExistsAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext)
#endif
        {
            FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient);

            operationContext = operationContext ?? new OperationContext();

#if ASPNET_K
            return(Task.Run(async() =>
            {
                bool exists = await this.ExistsAsync(modifiedOptions, operationContext, cancellationToken);
#else
            return AsyncInfo.Run(async(token) =>
            {
                bool exists = await this.ExistsAsync(modifiedOptions, operationContext).AsTask(token);
#endif

                if (!exists)
                {
                    return false;
                }

                try
                {
#if ASPNET_K
                    await this.DeleteAsync(accessCondition, modifiedOptions, operationContext, cancellationToken);
#else
                    await this.DeleteAsync(accessCondition, modifiedOptions, operationContext).AsTask(token);
#endif
                    return true;
                }
                catch (Exception)
                {
                    if (operationContext.LastResult.HttpStatusCode == (int)HttpStatusCode.NotFound)
                    {
                        StorageExtendedErrorInformation extendedInfo = operationContext.LastResult.ExtendedErrorInformation;
                        if ((extendedInfo == null) ||
                            (extendedInfo.ErrorCode == FileErrorCodeStrings.ShareNotFound))
                        {
                            return false;
                        }
                        else
                        {
                            throw;
                        }
                    }
                    else
                    {
                        throw;
                    }
                }
#if ASPNET_K
            }, cancellationToken));
#else
});
#endif
        }
Exemplo n.º 8
0
        public IAsyncAction FetchAttributesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext)
        {
            FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient);

            return(AsyncInfo.Run(async(token) => await Executor.ExecuteAsyncNullReturn(
                                     this.FetchAttributesImpl(accessCondition, modifiedOptions),
                                     modifiedOptions.RetryPolicy,
                                     operationContext,
                                     token)));
        }
Exemplo n.º 9
0
        public IAsyncOperation <bool> ExistsAsync(FileRequestOptions options, OperationContext operationContext)
        {
            FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient);

            return(AsyncInfo.Run(async(token) => await Executor.ExecuteAsync(
                                     this.ExistsImpl(modifiedOptions),
                                     modifiedOptions.RetryPolicy,
                                     operationContext,
                                     token)));
        }
Exemplo n.º 10
0
        public virtual Task <ShareStats> GetStatsAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
        {
            FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient);

            return(Task.Run(async() => await Executor.ExecuteAsync <ShareStats>(
                                this.GetStatsImpl(modifiedOptions),
                                modifiedOptions.RetryPolicy,
                                operationContext,
                                cancellationToken), cancellationToken));
        }
Exemplo n.º 11
0
        public virtual Task <FileSharePermissions> GetPermissionsAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
        {
            FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient);

            return(Task.Run(async() => await Executor.ExecuteAsync <FileSharePermissions>(
                                this.GetPermissionsImpl(accessCondition, modifiedOptions),
                                modifiedOptions.RetryPolicy,
                                operationContext,
                                cancellationToken), cancellationToken));
        }
 public virtual Task SetServicePropertiesAsync(FileServiceProperties properties, FileRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken)
 {
     requestOptions   = FileRequestOptions.ApplyDefaults(requestOptions, this);
     operationContext = operationContext ?? new OperationContext();
     return(Executor.ExecuteAsync(
                this.SetServicePropertiesImpl(properties, requestOptions),
                requestOptions.RetryPolicy,
                operationContext,
                cancellationToken));
 }
Exemplo n.º 13
0
        public virtual Task SetMetadataAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
        {
            FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient);

            return(Task.Run(async() => await Executor.ExecuteAsyncNullReturn(
                                this.SetMetadataImpl(accessCondition, modifiedOptions),
                                modifiedOptions.RetryPolicy,
                                operationContext,
                                cancellationToken), cancellationToken));
        }
Exemplo n.º 14
0
        public Task CreateAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
        {
            FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient);

            return(Task.Run(async() => await Executor.ExecuteAsyncNullReturn(
                                this.CreateDirectoryImpl(modifiedOptions),
                                modifiedOptions.RetryPolicy,
                                operationContext,
                                cancellationToken), cancellationToken));
        }
Exemplo n.º 15
0
        public virtual Task FetchAttributesAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
        {
            FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient);

            return(Executor.ExecuteAsyncNullReturn(
                       this.FetchAttributesImpl(accessCondition, modifiedOptions),
                       modifiedOptions.RetryPolicy,
                       operationContext,
                       cancellationToken));
        }
Exemplo n.º 16
0
        public IAsyncAction CreateAsync(FileRequestOptions options, OperationContext operationContext)
        {
            FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient);

            return(AsyncInfo.Run(async(token) => await Executor.ExecuteAsyncNullReturn(
                                     this.CreateDirectoryImpl(modifiedOptions),
                                     modifiedOptions.RetryPolicy,
                                     operationContext,
                                     token)));
        }
Exemplo n.º 17
0
        public virtual Task <bool> ExistsAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
        {
            FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient);

            return(Executor.ExecuteAsync(
                       this.ExistsImpl(modifiedOptions),
                       modifiedOptions.RetryPolicy,
                       operationContext,
                       cancellationToken));
        }
        public virtual Task DeleteAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
        {
            this.Share.AssertNoSnapshot();
            FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient);

            return(Task.Run(async() => await Executor.ExecuteAsyncNullReturn(
                                this.DeleteDirectoryImpl(accessCondition, modifiedOptions),
                                modifiedOptions.RetryPolicy,
                                operationContext,
                                cancellationToken), cancellationToken));
        }
        public virtual async Task <ShareResultSegment> ListSharesSegmentedAsync(string prefix, ShareListingDetails detailsIncluded, int?maxResults, FileContinuationToken currentToken, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
        {
            FileRequestOptions             modifiedOptions = FileRequestOptions.ApplyDefaults(options, this);
            ResultSegment <CloudFileShare> resultSegment   = await Executor.ExecuteAsync(
                this.ListSharesImpl(prefix, detailsIncluded, currentToken, maxResults, modifiedOptions),
                modifiedOptions.RetryPolicy,
                operationContext,
                cancellationToken).ConfigureAwait(false);

            return(new ShareResultSegment(resultSegment.Results, (FileContinuationToken)resultSegment.ContinuationToken));
        }
Exemplo n.º 20
0
        public virtual Task SetServicePropertiesAsync(FileServiceProperties properties, FileRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken)
        {
            FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(requestOptions, this);

            operationContext = operationContext ?? new OperationContext();
            return(Task.Run(async() => await Executor.ExecuteAsyncNullReturn(
                                this.SetServicePropertiesImpl(properties, modifiedOptions),
                                modifiedOptions.RetryPolicy,
                                operationContext,
                                cancellationToken), cancellationToken));
        }
Exemplo n.º 21
0
        public virtual Task CreateAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
        {
            this.Share.AssertNoSnapshot();
            FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient);

            return(Executor.ExecuteAsyncNullReturn(
                       this.CreateDirectoryImpl(modifiedOptions),
                       modifiedOptions.RetryPolicy,
                       operationContext,
                       cancellationToken));
        }
Exemplo n.º 22
0
        public virtual Task SetMetadataAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
        {
            this.Share.AssertNoSnapshot();
            FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient);

            return(Executor.ExecuteAsyncNullReturn(
                       this.SetMetadataImpl(accessCondition, modifiedOptions),
                       modifiedOptions.RetryPolicy,
                       operationContext,
                       cancellationToken));
        }
Exemplo n.º 23
0
        public IAsyncAction SetServicePropertiesAsync(FileServiceProperties properties, FileRequestOptions requestOptions, OperationContext operationContext)
        {
            FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(requestOptions, this);

            operationContext = operationContext ?? new OperationContext();
            return(AsyncInfo.Run(async(token) => await Executor.ExecuteAsyncNullReturn(
                                     this.SetServicePropertiesImpl(properties, modifiedOptions),
                                     modifiedOptions.RetryPolicy,
                                     operationContext,
                                     token)));
        }
Exemplo n.º 24
0
 public virtual ICancellableAsyncResult BeginSetServiceProperties(FileServiceProperties properties, FileRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state)
 {
     requestOptions   = FileRequestOptions.ApplyDefaults(requestOptions, this);
     operationContext = operationContext ?? new OperationContext();
     return(Executor.BeginExecuteAsync(
                this.SetServicePropertiesImpl(properties, requestOptions),
                requestOptions.RetryPolicy,
                operationContext,
                callback,
                state));
 }
Exemplo n.º 25
0
        public virtual async Task <FileResultSegment> ListFilesAndDirectoriesSegmentedAsync(string prefix, int?maxResults, FileContinuationToken currentToken, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
        {
            FileRequestOptions            modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient);
            ResultSegment <IListFileItem> resultSegment   = await Executor.ExecuteAsync(
                this.ListFilesAndDirectoriesImpl(maxResults, modifiedOptions, currentToken, prefix),
                modifiedOptions.RetryPolicy,
                operationContext,
                cancellationToken).ConfigureAwait(false);

            return(new FileResultSegment(resultSegment.Results, (FileContinuationToken)resultSegment.ContinuationToken));
        }
Exemplo n.º 26
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 virtual Task <FileServiceProperties> GetServicePropertiesAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
        {
            FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this);

            operationContext = operationContext ?? new OperationContext();

            return(Executor.ExecuteAsync(
                       this.GetServicePropertiesImpl(modifiedOptions),
                       modifiedOptions.RetryPolicy,
                       operationContext,
                       cancellationToken));
        }
Exemplo n.º 28
0
        public IAsyncOperation <ShareResultSegment> ListSharesSegmentedAsync(string prefix, ShareListingDetails detailsIncluded, int?maxResults, FileContinuationToken currentToken, FileRequestOptions options, OperationContext operationContext)
        {
            return(AsyncInfo.Run(async(token) =>
            {
                FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this);
                ResultSegment <CloudFileShare> resultSegment = await Executor.ExecuteAsync(
                    this.ListSharesImpl(prefix, detailsIncluded, currentToken, maxResults, modifiedOptions),
                    modifiedOptions.RetryPolicy,
                    operationContext,
                    token);

                return new ShareResultSegment(resultSegment.Results, (FileContinuationToken)resultSegment.ContinuationToken);
            }));
        }
        public virtual Task <bool> DeleteIfExistsAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
        {
            FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient);

            return(Task.Run(async() =>
            {
                try
                {
                    bool exists = await Executor.ExecuteAsync(
                        this.ExistsImpl(modifiedOptions),
                        modifiedOptions.RetryPolicy,
                        operationContext,
                        cancellationToken);

                    if (!exists)
                    {
                        return false;
                    }
                }
                catch (StorageException e)
                {
                    if (e.RequestInformation.HttpStatusCode != (int)HttpStatusCode.Forbidden)
                    {
                        throw;
                    }
                }

                try
                {
                    await Executor.ExecuteAsync(
                        this.DeleteDirectoryImpl(accessCondition, modifiedOptions),
                        modifiedOptions.RetryPolicy,
                        operationContext,
                        cancellationToken);

                    return true;
                }
                catch (StorageException e)
                {
                    if (e.RequestInformation.HttpStatusCode == (int)HttpStatusCode.NotFound)
                    {
                        return false;
                    }
                    else
                    {
                        throw;
                    }
                }
            }, cancellationToken));
        }
Exemplo n.º 30
0
        public virtual Task <FileResultSegment> ListFilesAndDirectoriesSegmentedAsync(int?maxResults, FileContinuationToken currentToken, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
        {
            FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient);

            return(Task.Run(async() =>
            {
                ResultSegment <IListFileItem> resultSegment = await Executor.ExecuteAsync(
                    this.ListFilesAndDirectoriesImpl(maxResults, modifiedOptions, currentToken),
                    modifiedOptions.RetryPolicy,
                    operationContext,
                    cancellationToken);

                return new FileResultSegment(resultSegment.Results, (FileContinuationToken)resultSegment.ContinuationToken);
            }, cancellationToken));
        }