本文整理汇总了C#中IBrightstarService.DoesStoreExist方法的典型用法代码示例。如果您正苦于以下问题:C# IBrightstarService.DoesStoreExist方法的具体用法?C# IBrightstarService.DoesStoreExist怎么用?C# IBrightstarService.DoesStoreExist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IBrightstarService
的用法示例。
在下文中一共展示了IBrightstarService.DoesStoreExist方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StoreModule
public StoreModule(IBrightstarService brightstarService, AbstractStorePermissionsProvider storePermissionsProvider)
{
this.RequiresBrightstarStorePermission(storePermissionsProvider, get:StorePermissions.Read, delete:StorePermissions.Admin);
Get["/{storeName}"] = parameters =>
{
var storeName = parameters["storeName"];
ViewBag.Title = storeName;
if (!brightstarService.DoesStoreExist(storeName)) return HttpStatusCode.NotFound;
if (Request.Method.ToUpperInvariant() == "HEAD")
{
IEnumerable < ICommitPointInfo > commitPoints = brightstarService.GetCommitPoints(storeName, 0, 1);
var commit = commitPoints.First();
return
Negotiate.WithHeader("Last-Modified", commit.CommitTime.ToUniversalTime().ToString("r"))
.WithStatusCode(HttpStatusCode.OK)
.WithModel(new StoreResponseModel(parameters["storeName"]));
}
return new StoreResponseModel(parameters["storeName"]);
};
Delete["/{storeName}"] = parameters =>
{
var storeName = parameters["storeName"];
ViewBag.Title = "Deleted - " + storeName;
if (brightstarService.DoesStoreExist(storeName))
{
brightstarService.DeleteStore(storeName);
}
return Negotiate.WithMediaRangeModel(new MediaRange("text/html"),
new StoreDeletedModel {StoreName = storeName});
};
}
示例2: StoresModule
public StoresModule(IBrightstarService brightstarService, AbstractSystemPermissionsProvider systemPermissionsProvider)
{
this.RequiresBrightstarSystemPermission(systemPermissionsProvider, get:SystemPermissions.ListStores, post:SystemPermissions.CreateStore);
Get["/"] = parameters =>
{
ViewBag.Title = "Stores";
var stores = brightstarService.ListStores();
return
Negotiate.WithModel(new StoresResponseModel
{
Stores = stores.ToList()
});
};
Post["/"] = parameters =>
{
ViewBag.Title = "Stores";
var request = this.Bind<CreateStoreRequestObject>();
if (request == null || String.IsNullOrEmpty(request.StoreName))
{
return HttpStatusCode.BadRequest;
}
// Return 409 Conflict if attempt to create a store with a name that is currently in use
if (brightstarService.DoesStoreExist(request.StoreName))
{
return HttpStatusCode.Conflict;
}
// Attempt to create the store
try
{
PersistenceType? storePersistenceType = request.GetBrightstarPersistenceType();
if (storePersistenceType.HasValue)
{
brightstarService.CreateStore(request.StoreName, storePersistenceType.Value);
}
else
{
brightstarService.CreateStore(request.StoreName);
}
}
catch (ArgumentException)
{
return HttpStatusCode.BadRequest;
}
return
Negotiate.WithModel(new StoreResponseModel(request.StoreName))
.WithStatusCode(HttpStatusCode.Created);
};
}
示例3: 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;
//.........这里部分代码省略.........