本文整理汇总了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);
}
}
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例5: BreakLease
private static void BreakLease(CloudBlob blob)
{
try
{
blob.BreakLease(TimeSpan.Zero);
}
catch
{
}
try
{
blob.Metadata.Remove(leasedForTestTag);
blob.SetMetadata();
}
catch
{
}
}