本文整理汇总了C#中Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer.CheckNullObject方法的典型用法代码示例。如果您正苦于以下问题:C# CloudBlobContainer.CheckNullObject方法的具体用法?C# CloudBlobContainer.CheckNullObject怎么用?C# CloudBlobContainer.CheckNullObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer
的用法示例。
在下文中一共展示了CloudBlobContainer.CheckNullObject方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeleteBlob
/// <summary>
/// Deletes the BLOB.
/// </summary>
/// <param name="container">The container.</param>
/// <param name="blobIdentifier">The BLOB identifier.</param>
public static void DeleteBlob(CloudBlobContainer container, string blobIdentifier)
{
try
{
container.CheckNullObject("container");
var blob = container.GetBlockBlobReference(blobIdentifier);
blob.Delete();
}
catch (Exception ex)
{
throw ex.Handle("DeleteBlob", new { container = container == null ? null : container.Uri.ToString(), blobIdentifier = blobIdentifier });
}
}
示例2: QueryBlob
/// <summary>
/// Queries the BLOB.
/// </summary>
/// <param name="container">The container.</param>
/// <param name="contentType">Type of the content.</param>
/// <param name="md5">The MD5.</param>
/// <param name="length">The length.</param>
/// <param name="limitCount">The limit count.</param>
/// <returns>IEnumerable<CloudBlockBlob>.</returns>
public static IEnumerable<CloudBlockBlob> QueryBlob(CloudBlobContainer container, string contentType, string md5, long? length, int limitCount = 100)
{
try
{
container.CheckNullObject("container");
if (string.IsNullOrWhiteSpace(contentType) && string.IsNullOrWhiteSpace(md5) && length == null)
{
return container.ListBlobs().OfType<CloudBlockBlob>().Take(limitCount);
}
else
{
return container.ListBlobs(blobListingDetails: BlobListingDetails.Metadata)
.OfType<CloudBlockBlob>()
.Where(item =>
{
return ((string.IsNullOrWhiteSpace(contentType) ||
item.Properties.ContentType.Equals(contentType,
StringComparison.InvariantCultureIgnoreCase))
&&
(string.IsNullOrWhiteSpace(md5) ||
item.Properties.ContentMD5.Equals(md5,
StringComparison.InvariantCultureIgnoreCase))
&& (length == null || item.Properties.Length == length.Value));
}).Take(limitCount);
}
}
catch (Exception ex)
{
throw ex.Handle("QueryBlob", new { container = container == null ? null : container.Uri.ToString(), contentType, md5, length, limitCount });
}
}
示例3: ApplyBlobPolicy
/// <summary>
/// Applies the BLOB policy.
/// </summary>
/// <param name="container">The container.</param>
/// <param name="policyName">Name of the policy.</param>
/// <param name="expireOffsetInMinute">The expire offset in minute.</param>
/// <param name="permissions">The permissions.</param>
protected static void ApplyBlobPolicy(CloudBlobContainer container, string policyName, int expireOffsetInMinute = 10, SharedAccessBlobPermissions permissions = SharedAccessBlobPermissions.List)
{
container.CheckNullObject("container");
policyName.CheckEmptyString("policyName");
//Get the container's existing permissions.
var containerPermissions = new BlobContainerPermissions();
var sharedPolicy = new SharedAccessBlobPolicy()
{
SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(expireOffsetInMinute),
Permissions = permissions
};
//Add the new policy to the container's permissions.
containerPermissions.SharedAccessPolicies.Clear();
containerPermissions.SharedAccessPolicies.Add(policyName, sharedPolicy);
container.SetPermissions(containerPermissions);
}