當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。