当前位置: 首页>>代码示例>>C#>>正文


C# DeleteSnapshotsOption类代码示例

本文整理汇总了C#中DeleteSnapshotsOption的典型用法代码示例。如果您正苦于以下问题:C# DeleteSnapshotsOption类的具体用法?C# DeleteSnapshotsOption怎么用?C# DeleteSnapshotsOption使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DeleteSnapshotsOption类属于命名空间,在下文中一共展示了DeleteSnapshotsOption类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Delete

        /// <summary>
        /// Constructs a web request to delete a blob.
        /// </summary>
        /// <param name="uri">A <see cref="System.Uri"/> specifying the absolute URI to the blob.</param>
        /// <param name="timeout">An integer specifying the server timeout interval.</param>
        /// <param name="snapshot">A <see cref="DateTimeOffset"/> specifying the snapshot timestamp, if the blob is a snapshot.</param>
        /// <param name="deleteSnapshotsOption">A set of options indicating whether to delete only blobs, only snapshots, or both.</param>
        /// <param name="accessCondition">An <see cref="AccessCondition"/> object that represents the condition that must be met in order for the request to proceed.</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 that represents the context for the current operation.</param>
        /// <returns>A <see cref="System.Net.HttpWebRequest"/> object.</returns>
        public static HttpWebRequest Delete(Uri uri, int? timeout, DateTimeOffset? snapshot, DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, bool useVersionHeader, OperationContext operationContext)
        {
            if ((snapshot != null) && (deleteSnapshotsOption != DeleteSnapshotsOption.None))
            {
                throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, SR.DeleteSnapshotsNotValidError, "deleteSnapshotsOption", "snapshot"));
            }

            UriQueryBuilder builder = new UriQueryBuilder();
            BlobHttpWebRequestFactory.AddSnapshot(builder, snapshot);

            HttpWebRequest request = HttpWebRequestFactory.Delete(uri, builder, timeout, useVersionHeader, operationContext);

            switch (deleteSnapshotsOption)
            {
                case DeleteSnapshotsOption.None:
                    break; // nop

                case DeleteSnapshotsOption.IncludeSnapshots:
                    request.Headers.Add(
                        Constants.HeaderConstants.DeleteSnapshotHeader,
                        Constants.HeaderConstants.IncludeSnapshotsValue);
                    break;

                case DeleteSnapshotsOption.DeleteSnapshotsOnly:
                    request.Headers.Add(
                        Constants.HeaderConstants.DeleteSnapshotHeader,
                        Constants.HeaderConstants.SnapshotsOnlyValue);
                    break;
            }

            request.ApplyAccessCondition(accessCondition);
            return request;
        }
开发者ID:Gajendra-Bahakar,项目名称:azure-storage-net,代码行数:44,代码来源:BlobHttpWebRequestFactory.cs

示例2: DeleteIfExistsHandler

        private void DeleteIfExistsHandler(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, ChainedAsyncResult<bool> chainedResult)
        {
            lock (chainedResult.CancellationLockerObject)
            {
                ICancellableAsyncResult savedExistsResult = this.BeginExists(
                    options,
                    operationContext,
                    existsResult =>
                    {
                        chainedResult.UpdateCompletedSynchronously(existsResult.CompletedSynchronously);
                        lock (chainedResult.CancellationLockerObject)
                        {
                            chainedResult.CancelDelegate = null;
                            try
                            {
                                bool exists = this.EndExists(existsResult);
                                if (!exists)
                                {
                                    chainedResult.Result = false;
                                    chainedResult.OnComplete();
                                    return;
                                }

                                ICancellableAsyncResult savedDeleteResult = this.BeginDelete(
                                    deleteSnapshotsOption,
                                    accessCondition,
                                    options,
                                    operationContext,
                                    deleteResult =>
                                    {
                                        chainedResult.UpdateCompletedSynchronously(deleteResult.CompletedSynchronously);
                                        chainedResult.CancelDelegate = null;
                                        try
                                        {
                                            this.EndDelete(deleteResult);
                                            chainedResult.Result = true;
                                            chainedResult.OnComplete();
                                        }
                                        catch (StorageException e)
                                        {
                                            if (e.RequestInformation.HttpStatusCode == (int)HttpStatusCode.NotFound)
                                            {
                                                chainedResult.Result = false;
                                                chainedResult.OnComplete();
                                            }
                                            else
                                            {
                                                chainedResult.OnComplete(e);
                                            }
                                        }
                                        catch (Exception e)
                                        {
                                            chainedResult.OnComplete(e);
                                        }
                                    },
                                    null /* state */);

                                chainedResult.CancelDelegate = savedDeleteResult.Cancel;
                                if (chainedResult.CancelRequested)
                                {
                                    chainedResult.Cancel();
                                }
                            }
                            catch (Exception e)
                            {
                                chainedResult.OnComplete(e);
                            }
                        }
                    },
                    null /* state */);

                chainedResult.CancelDelegate = savedExistsResult.Cancel;
                if (chainedResult.CancelRequested)
                {
                    chainedResult.Cancel();
                }
            }
        }
开发者ID:jdkillian,项目名称:azure-sdk-for-net,代码行数:78,代码来源:CloudPageBlob.cs

示例3: BeginDelete

 public ICancellableAsyncResult BeginDelete(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state)
 {
     BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.PageBlob, this.ServiceClient);
     return Executor.BeginExecuteAsync(
         CloudBlobSharedImpl.DeleteBlobImpl(this, this.attributes, deleteSnapshotsOption, accessCondition, modifiedOptions),
         modifiedOptions.RetryPolicy,
         operationContext,
         callback,
         state);
 }
开发者ID:jdkillian,项目名称:azure-sdk-for-net,代码行数:10,代码来源:CloudPageBlob.cs

示例4: DeleteIfExists

        public bool DeleteIfExists(DeleteSnapshotsOption deleteSnapshotsOption = DeleteSnapshotsOption.None, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null)
        {
            BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.BlockBlob, this.ServiceClient);
            operationContext = operationContext ?? new OperationContext();

            bool exists = this.Exists(modifiedOptions, operationContext);
            if (!exists)
            {
                return false;
            }

            try
            {
                this.Delete(deleteSnapshotsOption, accessCondition, modifiedOptions, operationContext);
                return true;
            }
            catch (StorageException e)
            {
                if (e.RequestInformation.HttpStatusCode == (int)HttpStatusCode.NotFound)
                {
                    if ((e.RequestInformation.ExtendedErrorInformation == null) ||
                        (e.RequestInformation.ExtendedErrorInformation.ErrorCode == BlobErrorCodeStrings.BlobNotFound))
                    {
                        return false;
                    }
                    else
                    {
                        throw;
                    }
                }
                else
                {
                    throw;
                }
            }
        }
开发者ID:huoxudong125,项目名称:azure-sdk-for-net,代码行数:36,代码来源:CloudBlockBlob.cs

示例5: DeleteIfExistsAsync

 public Task<bool> DeleteIfExistsAsync(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
 {
     return AsyncExtensions.TaskFromApm(this.BeginDeleteIfExists, this.EndDeleteIfExists, deleteSnapshotsOption, accessCondition, options, operationContext, cancellationToken);
 }
开发者ID:huoxudong125,项目名称:azure-sdk-for-net,代码行数:4,代码来源:CloudBlockBlob.cs

示例6: DeleteAsync

 public IAsyncAction DeleteAsync(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
 {
     BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.PageBlob, this.ServiceClient);
     return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn(
         CloudBlobSharedImpl.DeleteBlobImpl(this, this.attributes, deleteSnapshotsOption, accessCondition, modifiedOptions),
         modifiedOptions.RetryPolicy,
         operationContext,
         token));
 }
开发者ID:nberardi,项目名称:azure-sdk-for-net,代码行数:9,代码来源:CloudPageBlob.cs

示例7: DeleteICloudBlob

 /// <summary>
 /// Delete azure blob
 /// </summary>
 /// <param name="blob">ICloudblob object</param>
 /// <param name="deleteSnapshotsOption">Delete snapshots option</param>
 /// <param name="accessCondition">Access condition</param>
 /// <param name="operationContext">Operation context</param>
 /// <returns>An enumerable collection of icloudblob</returns>
 public void DeleteICloudBlob(ICloudBlob blob, DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
 {
     blob.Delete(deleteSnapshotsOption, accessCondition, options, operationContext);
 }
开发者ID:NordPool,项目名称:azure-sdk-tools,代码行数:12,代码来源:StorageBlobManagement.cs

示例8: BeginDeleteIfExists

 public ICancellableAsyncResult BeginDeleteIfExists(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state)
 {
     throw new NotImplementedException();
 }
开发者ID:djnicholson,项目名称:CloudBlobBackedObject,代码行数:4,代码来源:MockCloudBlob.cs

示例9: DeleteAsync

 public Task DeleteAsync(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
 {
     throw new NotImplementedException();
 }
开发者ID:djnicholson,项目名称:CloudBlobBackedObject,代码行数:4,代码来源:MockCloudBlob.cs

示例10: DeleteAsync

 public virtual Task DeleteAsync(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
 {
     return this.DeleteAsync(deleteSnapshotsOption, accessCondition, options, operationContext, CancellationToken.None);
 }
开发者ID:tamram,项目名称:azure-storage-net,代码行数:4,代码来源:CloudBlob.cs

示例11: DeleteCloudBlobAsync

 /// <summary>
 /// Return a task that asynchronously delete the specified blob
 /// </summary>
 /// <param name="blob">CloudBlob object</param>
 /// <param name="deleteSnapshotsOption">Snapshot delete option</param>
 /// <param name="accessCondition">Access condition</param>
 /// <param name="requestOptions">Blob request option</param>
 /// <param name="operationContext">Operation context</param>
 /// <param name="cmdletCancellationToken">Cancellation token</param>
 /// <returns>Return a task that asynchronously delete the specified blob</returns>
 public Task DeleteCloudBlobAsync(CloudBlob blob, DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions requestOptions, OperationContext operationContext, CancellationToken cmdletCancellationToken)
 {
     return Task.Factory.StartNew(() => this.DeleteCloudBlob(blob, deleteSnapshotsOption, accessCondition, requestOptions, operationContext));
 }
开发者ID:dulems,项目名称:azure-powershell,代码行数:14,代码来源:MockStorageBlobManagement.cs

示例12: DeleteCloudBlob

        /// <summary>
        /// Delete azure blob
        /// </summary>
        /// <param name="blob">Cloudblob object</param>
        /// <param name="deleteSnapshotsOption">Delete snapshots option</param>
        /// <param name="accessCondition">Access condition</param>
        /// <param name="operationContext">Operation context</param>
        /// <returns>An enumerable collection of CloudBlob</returns>
        public void DeleteCloudBlob(CloudBlob blob, DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
        {
            CloudBlobContainer container = blob.Container;

            if (!this.DoesContainerExist(container, null, null))
            {
                throw new StorageException(ContainerNotFound);
            }
            else if (ContainerBlobs.ContainsKey(container.Name))
            {
                List<CloudBlob> blobList = ContainerBlobs[container.Name];
                
                foreach (CloudBlob blobRef in blobList)
                {
                    if (blobRef.Name == blob.Name)
                    {
                        blobList.Remove(blobRef);
                        return;
                    }
                }
            }

            throw new StorageException(BlobNotFound);
        }
开发者ID:dulems,项目名称:azure-powershell,代码行数:32,代码来源:MockStorageBlobManagement.cs

示例13: DeleteIfExistsAsync

        public IAsyncOperation<bool> DeleteIfExistsAsync(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
        {
            BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, this.BlobType, this.ServiceClient);
            operationContext = operationContext ?? new OperationContext();

            return AsyncInfo.Run(async (token) =>
            {
                bool exists = await this.ExistsAsync(modifiedOptions, operationContext).AsTask(token);

                if (!exists)
                {
                    return false;
                }

                try
                {
                    await this.DeleteAsync(deleteSnapshotsOption, accessCondition, modifiedOptions, operationContext).AsTask(token);
                    return true;
                }
                catch (Exception)
                {
                    if (operationContext.LastResult.HttpStatusCode == (int)HttpStatusCode.NotFound)
                    {
                        StorageExtendedErrorInformation extendedInfo = operationContext.LastResult.ExtendedErrorInformation;
                        if ((extendedInfo == null) ||
                            (extendedInfo.ErrorCode == BlobErrorCodeStrings.BlobNotFound))
                        {
                            return false;
                        }
                        else
                        {
                            throw;
                        }
                    }
                    else
                    {
                        throw;
                    }
                }
            });
        }
开发者ID:huoxudong125,项目名称:azure-sdk-for-net,代码行数:41,代码来源:CloudBlockBlob.cs

示例14: DeleteICloudBlob

        /// <summary>
        /// Delete azure blob
        /// </summary>
        /// <param name="blob">ICloudblob object</param>
        /// <param name="deleteSnapshotsOption">Delete snapshots option</param>
        /// <param name="accessCondition">Access condition</param>
        /// <param name="operationContext">Operation context</param>
        /// <returns>An enumerable collection of icloudblob</returns>
        public void DeleteICloudBlob(ICloudBlob blob, DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
        {
            CloudBlobContainer container = blob.Container;

            if (!ContainerBlobs.ContainsKey(container.Name))
            {
                return;
            }
            else
            {
                List<ICloudBlob> blobList = ContainerBlobs[container.Name];

                foreach (ICloudBlob blobRef in blobList)
                {
                    if (blobRef.Name == blob.Name)
                    {
                        blobList.Remove(blobRef);
                        return;
                    }
                }
            }
        }
开发者ID:johnkors,项目名称:azure-sdk-tools,代码行数:30,代码来源:MockStorageBlobManagement.cs

示例15: DeleteIfExists

 public bool DeleteIfExists(DeleteSnapshotsOption deleteSnapshotsOption = DeleteSnapshotsOption.None, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null)
 {
     throw new NotImplementedException();
 }
开发者ID:djnicholson,项目名称:CloudBlobBackedObject,代码行数:4,代码来源:MockCloudBlob.cs


注:本文中的DeleteSnapshotsOption类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。