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


C# CloudBlob.SetMetadata方法代码示例

本文整理汇总了C#中Microsoft.WindowsAzure.StorageClient.CloudBlob.SetMetadata方法的典型用法代码示例。如果您正苦于以下问题:C# CloudBlob.SetMetadata方法的具体用法?C# CloudBlob.SetMetadata怎么用?C# CloudBlob.SetMetadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.WindowsAzure.StorageClient.CloudBlob的用法示例。


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

示例1: DoOnce

 public static void DoOnce(CloudBlob blob, Action action, TimeSpan pollingFrequency)
 {
     // blob.Exists has the side effect of calling blob.FetchAttributes, which populates the metadata collection
     while (!blob.Exists() || blob.Metadata["progress"] != "done")
     {
         using (var arl = new AutoRenewLease(blob))
         {
             if (arl.HasLease)
             {
                 action();
                 blob.Metadata["progress"] = "done";
                 blob.SetMetadata(arl.leaseId);
             }
             else
             {
                 Thread.Sleep(pollingFrequency);
             }
         }
     }
 }
开发者ID:TechSmith,项目名称:WazStorageExtensions,代码行数:20,代码来源:AutoRenewLease.cs

示例2: WriteWithoutCompression

        static long WriteWithoutCompression(CloudBlob blob, BlobRequestOptions mapped, Action<Stream> writer)
        {
            var md5 = MD5.Create();
            long position;
            using (var stream = blob.OpenWrite(mapped))
            {
                using (var crypto = new CryptoStream(stream, md5, CryptoStreamMode.Write))
                {
                    writer(crypto);
                }

                position = stream.Position;
            }
            blob.Metadata[LokadHashFieldName] = Convert.ToBase64String(md5.Hash);
            blob.SetMetadata();
            return position;
        }
开发者ID:higheredgrowth,项目名称:lokad-cqrs,代码行数:17,代码来源:BlobStorageUtil.cs

示例3: DoEvery

 public static void DoEvery(CloudBlob blob, TimeSpan interval, Action action)
 {
     while (true)
     {
         var lastPerformed = DateTimeOffset.MinValue;
         using (var arl = new AutoRenewLease(blob))
         {
             if (arl.HasLease)
             {
                 blob.FetchAttributes();
                 DateTimeOffset.TryParseExact(blob.Metadata["lastPerformed"], "R", CultureInfo.CurrentCulture, DateTimeStyles.AdjustToUniversal, out lastPerformed);
                 if (DateTimeOffset.UtcNow >= lastPerformed + interval)
                 {
                     action();
                     lastPerformed = DateTimeOffset.UtcNow;
                     blob.Metadata["lastPerformed"] = lastPerformed.ToString("R");
                     blob.SetMetadata(arl.leaseId);
                 }
             }
         }
         var timeLeft = (lastPerformed + interval) - DateTimeOffset.UtcNow;
         var minimum = TimeSpan.FromSeconds(5); // so we're not polling the leased blob too fast
         Thread.Sleep(
             timeLeft > minimum
             ? timeLeft
             : minimum);
     }
 }
开发者ID:sushant2517,项目名称:WazStorageExtensions,代码行数:28,代码来源:AutoRenewLease.cs

示例4: WriteWithCompression

 static long WriteWithCompression(CloudBlob blob, BlobRequestOptions mapped, Action<Stream> writer)
 {
     long position;
     var md5 = MD5.Create();
     blob.Properties.ContentEncoding = "gzip";
     using (var stream = blob.OpenWrite(mapped))
     {
         using (var crypto = new CryptoStream(stream, md5, CryptoStreamMode.Write))
         using (var compress = new GZipStream(crypto, CompressionMode.Compress, true))
         {
             writer(compress);
         }
         position = stream.Position;
     }
     blob.Metadata[LokadHashFieldName] = Convert.ToBase64String(md5.Hash);
     blob.SetMetadata();
     return position;
 }
开发者ID:higheredgrowth,项目名称:lokad-cqrs,代码行数:18,代码来源:BlobStorageUtil.cs

示例5: BreakLease

 private static void BreakLease(CloudBlob blob)
 {
     try
     {
         blob.BreakLease(TimeSpan.Zero);
     }
     catch
     {
     }
     try
     {
         blob.Metadata.Remove(leasedForTestTag);
         blob.SetMetadata();
     }
     catch
     {
     }
 }
开发者ID:amido,项目名称:Amido.Testing,代码行数:18,代码来源:BlobStorage.cs


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