本文整理汇总了C#中IHttpContext.ExtractQueryInputs方法的典型用法代码示例。如果您正苦于以下问题:C# IHttpContext.ExtractQueryInputs方法的具体用法?C# IHttpContext.ExtractQueryInputs怎么用?C# IHttpContext.ExtractQueryInputs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IHttpContext
的用法示例。
在下文中一共展示了IHttpContext.ExtractQueryInputs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Respond
public override void Respond(IHttpContext context)
{
RavenJArray itemsToLoad;
if(context.Request.HttpMethod == "POST")
itemsToLoad = context.ReadJsonArray();
else
itemsToLoad = new RavenJArray(context.Request.QueryString.GetValues("id"));
var result = new MultiLoadResult();
var loadedIds = new HashSet<string>();
var includes = context.Request.QueryString.GetValues("include") ?? new string[0];
var transformer = context.Request.QueryString["transformer"] ?? context.Request.QueryString["resultTransformer"];
var queryInputs = context.ExtractQueryInputs();
var transactionInformation = GetRequestTransaction(context);
var includedEtags = new List<byte>();
Database.TransactionalStorage.Batch(actions =>
{
foreach (RavenJToken item in itemsToLoad)
{
var value = item.Value<string>();
if(loadedIds.Add(value)==false)
continue;
JsonDocument documentByKey = string.IsNullOrEmpty(transformer)
? Database.Get(value, transactionInformation)
: Database.GetWithTransformer(value, transformer, transactionInformation, queryInputs);
if (documentByKey == null)
continue;
result.Results.Add(documentByKey.ToJson());
if (documentByKey.Etag != null)
{
includedEtags.AddRange(documentByKey.Etag.ToByteArray());
}
includedEtags.Add((documentByKey.NonAuthoritativeInformation ?? false) ? (byte)0 : (byte)1);
}
var addIncludesCommand = new AddIncludesCommand(Database, transactionInformation, (etag, includedDoc) =>
{
includedEtags.AddRange(etag.ToByteArray());
result.Includes.Add(includedDoc);
}, includes, loadedIds);
foreach (var item in result.Results.Where(item => item != null))
{
addIncludesCommand.Execute(item);
}
});
Etag computedEtag;
using (var md5 = MD5.Create())
{
var computeHash = md5.ComputeHash(includedEtags.ToArray());
computedEtag = Etag.Parse(computeHash);
}
if (context.MatchEtag(computedEtag))
{
context.SetStatusToNotModified();
return;
}
context.WriteETag(computedEtag);
context.WriteJson(result);
}