本文整理汇总了C#中IBrightstarService.ListNamedGraphs方法的典型用法代码示例。如果您正苦于以下问题:C# IBrightstarService.ListNamedGraphs方法的具体用法?C# IBrightstarService.ListNamedGraphs怎么用?C# IBrightstarService.ListNamedGraphs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IBrightstarService
的用法示例。
在下文中一共展示了IBrightstarService.ListNamedGraphs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GraphsModule
public GraphsModule(IBrightstarService brightstarService,
AbstractStorePermissionsProvider storePermissionsProvider)
{
this.RequiresBrightstarStorePermission(storePermissionsProvider, get:StorePermissions.Read, put:StorePermissions.SparqlUpdate, post:StorePermissions.SparqlUpdate, delete:StorePermissions.SparqlUpdate);
Get["/{storeName}/graphs"] = parameters =>
{
if (!brightstarService.DoesStoreExist(parameters["storeName"])) return HttpStatusCode.NotFound;
Uri graphUri;
if (Request.Query["default"] == null && Request.Query["graph"] == null)
{
// Get with no default or graph parameter returns a list of graphs
// This is not part of the SPARQL 1.1 Graph Store protocol, but a useful extension
// The returned value is a SPARQL results set with a single variable named "graphUri"
// Acceptable media types are the supported SPARQL results set formats
return
Negotiate.WithModel(
new GraphListModel(brightstarService.ListNamedGraphs(parameters["storeName"])));
}
if (!TryGetGraphUri(out graphUri))
{
// Will get here if the value of the graph parameter is parsed as a relative URI
return HttpStatusCode.BadRequest;
}
try
{
// Return the serialized content of the graph
return SerializeGraph(brightstarService, parameters["storeName"], graphUri.ToString());
}
catch (BrightstarStoreNotModifiedException)
{
return HttpStatusCode.NotModified;
}
};
Put["/{storeName}/graphs"] = parameters =>
{
var storeParam = parameters["storeName"];
var store = storeParam.Value as string;
Uri graphUri;
if (!brightstarService.DoesStoreExist(store)) return HttpStatusCode.NotFound;
if (!TryGetGraphUri(out graphUri))
{
return HttpStatusCode.BadRequest;
}
var graphUriStr = graphUri.ToString();
bool isNewGraph = !graphUriStr.Equals(Constants.DefaultGraphUri) &&
!(brightstarService.ListNamedGraphs(store).Any(x => x.Equals(graphUriStr)));
try
{
var rdfFormat = GetRequestBodyFormat();
if (rdfFormat == null) return HttpStatusCode.NotAcceptable;
var rdfPayload = ParseBody(rdfFormat);
var sparqlUpdate = graphUri.ToString().Equals(Constants.DefaultGraphUri) ?
String.Format(UpdateDefaultGraph, rdfPayload) :
String.Format(UpdateNamedGraph, graphUri, rdfPayload);
var job = brightstarService.ExecuteUpdate(store, sparqlUpdate, true, "Update Graph " + graphUri);
return job.JobCompletedOk
? (isNewGraph ? HttpStatusCode.Created : HttpStatusCode.NoContent)
: HttpStatusCode.InternalServerError;
}
catch (RdfException)
{
return HttpStatusCode.BadRequest;
}
};
Post["/{storeName}/graphs"] = parameters =>
{
var storeParam = parameters["storeName"];
var store = storeParam.Value as string;
Uri graphUri;
if (!brightstarService.DoesStoreExist(store)) return HttpStatusCode.NotFound;
if (!TryGetGraphUri(out graphUri))
{
return HttpStatusCode.BadRequest;
}
var graphUriStr = graphUri.ToString();
var isNewGraph = !graphUriStr.Equals(Constants.DefaultGraphUri) &&
!(brightstarService.ListNamedGraphs(store).Any(x => x.Equals(graphUriStr)));
try
{
var rdfFormat = GetRequestBodyFormat();
if (rdfFormat == null) return HttpStatusCode.NotAcceptable;
var rdfPayload = ParseBody(rdfFormat);
var sparqlUpdate = graphUri.ToString().Equals(Constants.DefaultGraphUri) ?
String.Format(MergeDefaultGraph, rdfPayload) :
String.Format(MergeNamedGraph, graphUri, rdfPayload);
var job = brightstarService.ExecuteUpdate(store, sparqlUpdate, true, "Update Graph " + graphUri);
return job.JobCompletedOk
? (isNewGraph ? HttpStatusCode.Created : HttpStatusCode.NoContent)
: HttpStatusCode.InternalServerError;
}
catch (RdfException)
{
return HttpStatusCode.BadRequest;
//.........这里部分代码省略.........