本文整理汇总了C#中IHttpContext.GetStart方法的典型用法代码示例。如果您正苦于以下问题:C# IHttpContext.GetStart方法的具体用法?C# IHttpContext.GetStart怎么用?C# IHttpContext.GetStart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IHttpContext
的用法示例。
在下文中一共展示了IHttpContext.GetStart方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Respond
public override void Respond(IHttpContext context)
{
var namesOnlyString = context.Request.QueryString["namesOnly"];
bool namesOnly;
RavenJArray indexes;
if(bool.TryParse(namesOnlyString, out namesOnly) && namesOnly)
indexes = Database.GetIndexNames(context.GetStart(), context.GetPageSize(Database.Configuration.MaxPageSize));
else
indexes = Database.GetIndexes(context.GetStart(), context.GetPageSize(Database.Configuration.MaxPageSize));
context.WriteJson(indexes);
}
示例2: Respond
public override void Respond(IHttpContext context)
{
switch (context.Request.HttpMethod)
{
case "GET":
long documentsCount = 0;
Etag lastDocEtag = Etag.Empty;
Database.TransactionalStorage.Batch(accessor =>
{
lastDocEtag = accessor.Staleness.GetMostRecentDocumentEtag();
documentsCount = accessor.Documents.GetDocumentsCount();
});
lastDocEtag = lastDocEtag.HashWith(BitConverter.GetBytes(documentsCount));
if (context.MatchEtag(lastDocEtag))
{
context.SetStatusToNotModified();
}
else
{
context.WriteHeaders(new RavenJObject(), lastDocEtag);
using (var cts = new CancellationTokenSource())
{
cts.TimeoutAfter(Settings.DatbaseOperationTimeout);
var startsWith = context.Request.QueryString["startsWith"];
if (string.IsNullOrEmpty(startsWith))
context.WriteJson(Database.GetDocuments(context.GetStart(), context.GetPageSize(Database.Configuration.MaxPageSize), context.GetEtagFromQueryString(), cts.Token));
else
context.WriteJson(Database.GetDocumentsWithIdStartingWith(
startsWith,
context.Request.QueryString["matches"],
context.Request.QueryString["exclude"],
context.GetStart(),
context.GetPageSize(Database.Configuration.MaxPageSize),
cts.Token));
}
}
break;
case "POST":
var json = context.ReadJson();
var id = Database.Put(null, Etag.Empty, json,
context.Request.Headers.FilterHeaders(),
GetRequestTransaction(context));
context.SetStatusToCreated("/docs/" + Uri.EscapeUriString(id.Key));
context.WriteJson(id);
break;
}
}
示例3: Respond
public override void Respond(IHttpContext context)
{
switch (context.Request.HttpMethod)
{
case "GET":
long documentsCount = 0;
Guid lastDocEtag = Guid.Empty;
Database.TransactionalStorage.Batch(accessor =>
{
lastDocEtag = accessor.Staleness.GetMostRecentDocumentEtag();
documentsCount = accessor.Documents.GetDocumentsCount();
});
var array = lastDocEtag.ToByteArray().Concat(BitConverter.GetBytes(documentsCount)).ToArray();
using (var md5 = MD5.Create())
{
var hashed = md5.ComputeHash(array);
lastDocEtag = new Guid(hashed);
}
if (context.MatchEtag(lastDocEtag))
{
context.SetStatusToNotModified();
}
else
{
context.WriteHeaders(new RavenJObject(), lastDocEtag);
var startsWith = context.Request.QueryString["startsWith"];
if (string.IsNullOrEmpty(startsWith))
context.WriteJson(Database.GetDocuments(context.GetStart(), context.GetPageSize(Database.Configuration.MaxPageSize), context.GetEtagFromQueryString()));
else
context.WriteJson(Database.GetDocumentsWithIdStartingWith(
startsWith,
context.Request.QueryString["matches"],
context.GetStart(),
context.GetPageSize(Database.Configuration.MaxPageSize)));
}
break;
case "POST":
var json = context.ReadJson();
var id = Database.Put(null, Guid.Empty, json,
context.Request.Headers.FilterHeaders(),
GetRequestTransaction(context));
context.SetStatusToCreated("/docs/" + Uri.EscapeUriString(id.Key));
context.WriteJson(id);
break;
}
}
示例4: Respond
public override void Respond(IHttpContext context)
{
using (context.Response.Streaming())
{
context.Response.ContentType = "application/json; charset=utf-8";
using (var writer = new JsonTextWriter(new StreamWriter(context.Response.OutputStream)))
{
writer.WriteStartObject();
writer.WritePropertyName("Results");
writer.WriteStartArray();
Database.TransactionalStorage.Batch(accessor =>
{
var startsWith = context.Request.QueryString["startsWith"];
int pageSize = context.GetPageSize(int.MaxValue);
if (string.IsNullOrEmpty(context.Request.QueryString["pageSize"]))
pageSize = int.MaxValue;
// we may be sending a LOT of documents to the user, and most
// of them aren't going to be relevant for other ops, so we are going to skip
// the cache for that, to avoid filling it up very quickly
using (DocumentCacher.SkipSettingDocumentsInDocumentCache())
{
if (string.IsNullOrEmpty(startsWith))
{
Database.GetDocuments(context.GetStart(), pageSize, context.GetEtagFromQueryString(),
doc => doc.WriteTo(writer));
}
else
{
Database.GetDocumentsWithIdStartingWith(
startsWith,
context.Request.QueryString["matches"],
context.Request.QueryString["exclude"],
context.GetStart(),
pageSize,
doc => doc.WriteTo(writer));
}
}
});
writer.WriteEndArray();
writer.WriteEndObject();
writer.Flush();
}
}
}
示例5: Respond
public override void Respond(IHttpContext context)
{
var op = context.Request.QueryString["op"] == "from" ? "from" : "to";
var match = urlMatcher.Match(context.GetRequestUrl());
var docId = Uri.UnescapeDataString(match.Groups[1].Value);
int totalCountReferencing = -1;
List<string> results = null;
Database.TransactionalStorage.Batch(accessor =>
{
totalCountReferencing = accessor.Indexing.GetCountOfDocumentsReferencing(docId);
var documentsReferencing =
op == "from"
? accessor.Indexing.GetDocumentsReferencesFrom(docId)
: accessor.Indexing.GetDocumentsReferencing(docId);
results =
documentsReferencing
.Skip(context.GetStart())
.Take(context.GetPageSize(Database.Configuration.MaxPageSize))
.ToList();
});
context.WriteJson(new
{
TotalCountReferencing = totalCountReferencing,
Results = results
});
}
示例6: Respond
public override void Respond(IHttpContext context)
{
var array = Database.GetAttachments(context.GetStart(),
context.GetPageSize(Database.Configuration.MaxPageSize),
context.GetEtagFromQueryString());
context.WriteJson(array);
}
示例7: Respond
public override void Respond(IHttpContext context)
{
if (EnsureSystemDatabase(context) == false)
return;
// This responder is NOT secured, and anyone can access it.
// Because of that, we need to provide explicit security here.
// Anonymous Access - All / Get / Admin
// Show all dbs
// Anonymous Access - None
// Show only the db that you have access to (read / read-write / admin)
// If admin, show all dbs
List<string> approvedDatabases = null;
var databases = Database.GetDocumentsWithIdStartingWith("Raven/Databases/", null, null, context.GetStart(),
context.GetPageSize(Database.Configuration.MaxPageSize),
CancellationToken.None);
var data = databases
.Select(x => x.Value<RavenJObject>("@metadata").Value<string>("@id").Replace("Raven/Databases/", string.Empty))
.ToArray();
if (server.SystemConfiguration.AnonymousUserAccessMode == AnonymousUserAccessMode.None)
{
var user = server.RequestAuthorizer.GetUser(context);
if(user == null)
{
return;
}
if (user.IsAdministrator(server.SystemConfiguration.AnonymousUserAccessMode) == false)
{
approvedDatabases = server.RequestAuthorizer.GetApprovedDatabases(user, context, data);
}
}
Etag lastDocEtag = Etag.Empty;
Database.TransactionalStorage.Batch(accessor =>
{
lastDocEtag = accessor.Staleness.GetMostRecentDocumentEtag();
});
if (context.MatchEtag(lastDocEtag))
{
context.SetStatusToNotModified();
}
else
{
context.WriteHeaders(new RavenJObject(), lastDocEtag);
if(approvedDatabases != null)
{
data = data.Where(s => approvedDatabases.Contains(s)).ToArray();
}
context.WriteJson(data);
}
}
示例8: Respond
public override void Respond(IHttpContext context)
{
context.WriteJson(
Queues
.GetQueueNames(context.GetStart(),context.GetPageSize(Configuration.MaxPageSize))
.Select(x=>Queues.Statistics(x))
);
}
示例9: Respond
public override void Respond(IHttpContext context)
{
switch (context.Request.HttpMethod)
{
case "GET":
context.WriteJson(Database.GetDocumentsWithIdStartingWith("Raven/Databases/", context.GetStart(), context.GetPageSize(Database.Configuration.MaxPageSize)));
break;
}
}
示例10: Respond
public override void Respond(IHttpContext context)
{
var match = urlMatcher.Match(context.GetRequestUrl());
var transformer = match.Groups[1].Value;
switch (context.Request.HttpMethod)
{
case "GET":
if (string.IsNullOrEmpty(transformer) == false && transformer != "/")
{
var transformerDefinition = Database.GetTransformerDefinition(transformer);
if (transformerDefinition == null)
{
context.SetStatusToNotFound();
return;
}
context.WriteJson(new
{
Transformer = transformerDefinition,
});
break;
}
var namesOnlyString = context.Request.QueryString["namesOnly"];
bool namesOnly;
RavenJArray transformers;
if (bool.TryParse(namesOnlyString, out namesOnly) && namesOnly)
transformers = Database.GetTransformerNames(context.GetStart(), context.GetPageSize(Database.Configuration.MaxPageSize));
else
transformers = Database.GetTransformers(context.GetStart(), context.GetPageSize(Database.Configuration.MaxPageSize));
context.WriteJson(transformers);
break;
case "PUT":
HandlePut(context, transformer);
break;
case "DELETE":
context.SetStatusToDeleted();
Database.DeleteTransfom(transformer);
break;
}
}
示例11: Respond
public override void Respond(IHttpContext context)
{
switch (context.Request.HttpMethod)
{
case "GET":
Guid lastDocEtag = Guid.Empty;
Database.TransactionalStorage.Batch(accessor =>
{
lastDocEtag = accessor.Staleness.GetMostRecentDocumentEtag();
});
if (context.MatchEtag(lastDocEtag))
{
context.SetStatusToNotModified();
}
else
{
context.WriteHeaders(new RavenJObject(), lastDocEtag);
var startsWith = context.Request.QueryString["startsWith"];
if (string.IsNullOrEmpty(startsWith))
context.WriteJson(Database.GetDocuments(context.GetStart(), context.GetPageSize(Database.Configuration.MaxPageSize), context.GetEtagFromQueryString()));
else
context.WriteJson(Database.GetDocumentsWithIdStartingWith(
startsWith,
context.Request.QueryString["matches"],
context.GetStart(),
context.GetPageSize(Database.Configuration.MaxPageSize)));
}
break;
case "POST":
var json = context.ReadJson();
var id = Database.Put(null, Guid.Empty, json,
context.Request.Headers.FilterHeaders(),
GetRequestTransaction(context));
context.SetStatusToCreated("/docs/" + Uri.EscapeUriString(id.Key));
context.WriteJson(id);
break;
}
}
示例12: Respond
public override void Respond(IHttpContext context)
{
var match = urlMatcher.Match(context.GetRequestUrl());
var index = match.Groups[1].Value;
switch (context.Request.HttpMethod)
{
case "GET":
if (string.IsNullOrEmpty(index) == false && index != "/")
{
context.SetStatusToBadRequest();
context.WriteJson(new
{
Error = "Cannot GET from a specific transformer but got a request for: " + index.Substring(0)
});
return;
}
var namesOnlyString = context.Request.QueryString["namesOnly"];
bool namesOnly;
RavenJArray indexes;
if (bool.TryParse(namesOnlyString, out namesOnly) && namesOnly)
indexes = Database.GetTransformerNames(context.GetStart(), context.GetPageSize(Database.Configuration.MaxPageSize));
else
indexes = Database.GetTransformers(context.GetStart(), context.GetPageSize(Database.Configuration.MaxPageSize));
context.WriteJson(indexes);
break;
case "PUT":
var data = context.ReadJsonObject<TransformerDefinition>();
if (data == null || string.IsNullOrEmpty(data.TransformResults))
{
context.SetStatusToBadRequest();
context.Write("Expected json document with 'TransformResults' property");
return;
}
context.SetStatusToCreated("/transformers");
context.WriteJson(new { Transfomer = Database.PutTransform(index, data) });
break;
}
}
示例13: Respond
public override void Respond(IHttpContext context)
{
switch (context.Request.HttpMethod)
{
case "GET":
var startsWith = context.Request.QueryString["startsWith"];
if(string.IsNullOrEmpty(startsWith))
context.WriteJson(Database.GetDocuments(context.GetStart(), context.GetPageSize(Database.Configuration.MaxPageSize), context.GetEtagFromQueryString()));
else
context.WriteJson(Database.GetDocumentsWithIdStartingWith(startsWith, context.GetStart(),
context.GetPageSize(Database.Configuration.MaxPageSize)));
break;
case "POST":
var json = context.ReadJson();
var id = Database.Put(null, Guid.NewGuid(), json,
context.Request.Headers.FilterHeaders(isServerDocument: true),
GetRequestTransaction(context));
context.SetStatusToCreated("/docs/" + id);
context.WriteJson(id);
break;
}
}
示例14: Respond
public override void Respond(IHttpContext context)
{
context.Response.BufferOutput = false;
using (var writer = new JsonTextWriter(new StreamWriter(context.Response.OutputStream)))
{
writer.WriteStartObject();
writer.WritePropertyName("Results");
writer.WriteStartArray();
Database.TransactionalStorage.Batch(accessor =>
{
var startsWith = context.Request.QueryString["startsWith"];
int pageSize = context.GetPageSize(int.MaxValue);
if (string.IsNullOrEmpty(context.Request.QueryString["pageSize"]))
pageSize = int.MaxValue;
if (string.IsNullOrEmpty(startsWith))
{
Database.GetDocuments(context.GetStart(), pageSize, context.GetEtagFromQueryString(),
doc => doc.WriteTo(writer));
}
else
{
Database.GetDocumentsWithIdStartingWith(
startsWith,
context.Request.QueryString["matches"],
context.GetStart(),
pageSize,
doc => doc.WriteTo(writer));
}
});
writer.WriteEndArray();
writer.WriteEndObject();
writer.Flush();
}
}
示例15: Respond
public override void Respond(IHttpContext context)
{
switch (context.Request.HttpMethod)
{
case "GET":
context.WriteJson(Database.GetDocuments(context.GetStart(), context.GetPageSize(Database.Configuration.MaxPageSize), context.GetEtagFromQueryString()));
break;
case "POST":
var json = context.ReadJson();
var id = Database.Put(null, Guid.NewGuid(), json,
context.Request.Headers.FilterHeaders(),
GetRequestTransaction(context));
context.SetStatusToCreated("/docs/" + id);
context.WriteJson(id);
break;
}
}