本文整理汇总了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;
}
示例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();
}
}
}
示例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);
}
示例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;
}
}
}
示例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);
}
示例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));
}
示例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);
}
示例8: BeginDeleteIfExists
public ICancellableAsyncResult BeginDeleteIfExists(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state)
{
throw new NotImplementedException();
}
示例9: DeleteAsync
public Task DeleteAsync(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
{
throw new NotImplementedException();
}
示例10: DeleteAsync
public virtual Task DeleteAsync(DeleteSnapshotsOption deleteSnapshotsOption, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
{
return this.DeleteAsync(deleteSnapshotsOption, accessCondition, options, operationContext, CancellationToken.None);
}
示例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));
}
示例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);
}
示例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;
}
}
});
}
示例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;
}
}
}
}
示例15: DeleteIfExists
public bool DeleteIfExists(DeleteSnapshotsOption deleteSnapshotsOption = DeleteSnapshotsOption.None, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null)
{
throw new NotImplementedException();
}