本文整理汇总了C#中Etag.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Etag.ToString方法的具体用法?C# Etag.ToString怎么用?C# Etag.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Etag
的用法示例。
在下文中一共展示了Etag.ToString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PerformPost
public static HttpStatusCode PerformPost(string url, string payload, Etag requestEtag, out Etag responseEtag)
{
var request = WebRequest.Create(url);
if (requestEtag != null)
request.Headers.Add("If-None-Match", requestEtag.ToString());
request.Method = "POST";
byte[] buffer = Encoding.UTF8.GetBytes(payload);
request.GetRequestStream().Write(buffer, 0, buffer.Length);
using (var response = GetHttpResponseHandle304(request))
{
try
{
responseEtag = response.GetEtagHeader();
}
catch (Exception)
{
responseEtag = null;
}
return response.StatusCode;
}
}
示例2: PerformGet
public static HttpStatusCode PerformGet(string url, Etag requestEtag, out Etag responseEtag)
{
var getRequest = WebRequest.Create(url);
if(requestEtag != null)
getRequest.Headers.Add("If-None-Match", requestEtag.ToString());
using (var response = GetHttpResponseHandle304(getRequest))
{
try
{
responseEtag = response.GetEtagHeader();
}
catch (Exception)
{
responseEtag = null;
}
return response.StatusCode;
}
}
示例3: Touch
public void Touch(string name, string key, UuidType uuidType, out Etag preTouchEtag, out Etag afterTouchEtag)
{
var item = Read(name, key);
if (item == null)
{
afterTouchEtag = null;
preTouchEtag = null;
return;
}
preTouchEtag = item.Etag;
Remove(name, key);
afterTouchEtag = generator.CreateSequentialUuid(uuidType);
var internalKey = afterTouchEtag.ToString();
var internalKeyAsSlice = (Slice) internalKey;
tableStorage.Lists.Add(
writeBatch.Value,
internalKeyAsSlice,
new RavenJObject
{
{"name", name},
{"key", key},
{"etag", afterTouchEtag.ToByteArray()},
{"data", item.Data},
{"createdAt", item.CreatedAt}
});
var listsByName = tableStorage.Lists.GetIndex(Tables.Lists.Indices.ByName);
var listsByNameAndKey = tableStorage.Lists.GetIndex(Tables.Lists.Indices.ByNameAndKey);
var nameKey = CreateKey(name);
var nameKeySlice = (Slice) nameKey;
var nameAndKeySlice = (Slice) AppendToKey(nameKey, key);
listsByName.MultiAdd(writeBatch.Value, nameKeySlice, internalKeyAsSlice);
listsByNameAndKey.Add(writeBatch.Value, nameAndKeySlice, internalKey);
}
示例4: Read
public IEnumerable<ListItem> Read(string name, Etag start, Etag end, int take)
{
var listsByName = tableStorage.Lists.GetIndex(Tables.Lists.Indices.ByName);
using (var iterator = listsByName.MultiRead(Snapshot, CreateKey(name)))
{
if (!iterator.Seek(start.ToString()))
yield break;
int count = 0;
do
{
var etag = Etag.Parse(iterator.CurrentKey.ToString());
if (start.CompareTo(etag) >= 0)
continue;
if (end != null && end.CompareTo(etag) <= 0)
yield break;
count++;
yield return ReadInternal(etag);
}
while (iterator.MoveNext() && count < take);
}
}
示例5: WithEtagAndLastModified
public static Negotiator WithEtagAndLastModified(this Negotiator negotiator, Etag etag, DateTime responseLastModified)
{
var currentEtag = etag.ToString();
return negotiator
.WithHeader("ETag", currentEtag)
.WithHeader("Last-Modified", responseLastModified.ToString("R"));
}