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


C# CloudBlobContainer.CheckNullObject方法代码示例

本文整理汇总了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 });
            }
        }
开发者ID:rynnwang,项目名称:CommonSolution,代码行数:19,代码来源:AzureStorageManager.cs

示例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&lt;CloudBlockBlob&gt;.</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 });
     }
 }
开发者ID:rynnwang,项目名称:CommonSolution,代码行数:40,代码来源:AzureStorageManager.cs

示例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);
        }
开发者ID:rynnwang,项目名称:CommonSolution,代码行数:26,代码来源:AzureStorageManager.cs


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