• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# DeleteSnapshotsOption类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: Delete

        /// <summary>
        /// Constructs a web request to delete a blob.
        /// </summary>
        /// <param name="uri">The absolute URI to the blob.</param>
        /// <param name="timeout">The server timeout interval.</param>
        /// <param name="snapshot">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="leaseId">The lease ID, if the blob has an active lease.</param>
        /// <returns>A web request to use to perform the operation.</returns>
        public static HttpWebRequest Delete(Uri uri, int timeout, DateTime? snapshot, DeleteSnapshotsOption deleteSnapshotsOption, string leaseId)
        {
            UriQueryBuilder builder = new UriQueryBuilder();

            if (snapshot != null && deleteSnapshotsOption != DeleteSnapshotsOption.None)
            {
                throw new InvalidOperationException(String.Format(SR.DeleteSnapshotsNotValidError, "deleteSnapshotsOption", "snapshot"));
            }

            BlobRequest.AddSnapshot(builder, snapshot);

            var request = Request.Delete(uri, timeout, builder);

            Request.AddLeaseId(request, leaseId);

            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;
            }

            return request;
        }
开发者ID:nagyist,项目名称:azure-sdk-for-mono,代码行数:42,代码来源:BlobRequest.cs


示例17: DeleteIfExistsAsync

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


示例18: DeleteIfExistsAsync

        public IAsyncOperation<bool> DeleteIfExistsAsync(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
        {
            BlobRequestOptions modifiedOptions = BlobRequestOptions.ApplyDefaults(options, BlobType.PageBlob, this.ServiceClient);
            return AsyncInfo.Run(async (token) =>
            {
                bool exists = await Executor.ExecuteAsync(
                    CloudBlobSharedImpl.ExistsImpl(this, this.attributes, modifiedOptions),
                    modifiedOptions.RetryPolicy,
                    operationContext,
                    token);

                if (!exists)
                {
                    return false;
                }

                try
                {
                    await Executor.ExecuteAsync(
                        CloudBlobSharedImpl.DeleteBlobImpl(this, this.attributes, deleteSnapshotsOption, accessCondition, modifiedOptions),
                        modifiedOptions.RetryPolicy,
                        operationContext,
                        token);

                    return true;
                }
                catch (StorageException e)
                {
                    if (e.RequestInformation.HttpStatusCode == (int)HttpStatusCode.NotFound)
                    {
                        return false;
                    }
                    else
                    {
                        throw;
                    }
                }
            });
        }
开发者ID:nberardi,项目名称:azure-sdk-for-net,代码行数:39,代码来源:CloudPageBlob.cs


示例19: DeleteIfExistsAsync

        /// <summary>
        ///     Deletes the blob if it already exists asynchronously.
        /// </summary>
        /// <param name="cloudBlob">Cloud blob client.</param>
        /// <param name="deleteSnapshotsOption">Whether to only delete the blob, to delete the blob and all snapshots, or to only delete the snapshots.</param>
        /// <param name="accessCondition">
        ///     An <see cref="T:Microsoft.WindowsAzure.Storage.AccessCondition" /> object that represents the access conditions for the blob.
        /// </param>
        /// <param name="cancellationToken">Cancellation token.</param>
        /// <returns>
        ///     <c>true</c> if the blob did not already exist and was created; otherwise <c>false</c>.
        /// </returns>
        public static Task<bool> DeleteIfExistsAsync(
            this ICloudBlob cloudBlob,
            DeleteSnapshotsOption deleteSnapshotsOption = DeleteSnapshotsOption.None,
            AccessCondition accessCondition = null,
            CancellationToken cancellationToken = default (CancellationToken))
        {
            ICancellableAsyncResult asyncResult = cloudBlob.BeginDeleteIfExists(deleteSnapshotsOption, accessCondition, null, null, null, null);
            CancellationTokenRegistration registration = cancellationToken.Register(p => asyncResult.Cancel(), null);

            return Task<bool>.Factory.FromAsync(
                asyncResult,
                result =>
                    {
                        registration.Dispose();
                        return cloudBlob.EndDeleteIfExists(result);
                    });
        }
开发者ID:jorik041,项目名称:WindowsAzure,代码行数:29,代码来源:CloudBlobExtensions.cs


示例20: DeleteICloudBlobAsync

 /// <summary>
 /// Return a task that asynchronously delete the specified blob
 /// </summary>
 /// <param name="blob">ICloudBlob 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 DeleteICloudBlobAsync(ICloudBlob blob, DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken)
 {
     return blob.DeleteAsync(deleteSnapshotsOption, accessCondition, requestOptions, operationContext, cancellationToken);
 }
开发者ID:NordPool,项目名称:azure-sdk-tools,代码行数:14,代码来源:StorageBlobManagement.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# DeleteStackRequestMarshaller类代码示例发布时间:2022-05-24
下一篇:
C# DeleteSnapshotRequestMarshaller类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap