本文整理汇总了C#中IRdfHandler.HandleBaseUri方法的典型用法代码示例。如果您正苦于以下问题:C# IRdfHandler.HandleBaseUri方法的具体用法?C# IRdfHandler.HandleBaseUri怎么用?C# IRdfHandler.HandleBaseUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRdfHandler
的用法示例。
在下文中一共展示了IRdfHandler.HandleBaseUri方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Describe
/// <summary>
/// Gets the Description Graph based on the Query Results from the given Evaluation Context passing the resulting Triples to the given RDF Handler
/// </summary>
/// <param name="handler">RDF Handler</param>
/// <param name="context">SPARQL Evaluation Context</param>
public void Describe(IRdfHandler handler, SparqlEvaluationContext context)
{
try
{
handler.StartRdf();
//Apply Base URI and Namespaces to the Handler
if (context.Query != null)
{
if (context.Query.BaseUri != null)
{
if (!handler.HandleBaseUri(context.Query.BaseUri)) ParserHelper.Stop();
}
foreach (String prefix in context.Query.NamespaceMap.Prefixes)
{
if (!handler.HandleNamespace(prefix, context.Query.NamespaceMap.GetNamespaceUri(prefix))) ParserHelper.Stop();
}
}
//Get the Nodes needing describing
List<INode> nodes = this.GetNodes(handler, context);
if (nodes.Count > 0)
{
//If there is at least 1 Node then start describing
this.DescribeInternal(handler, context, nodes);
}
handler.EndRdf(true);
}
catch (RdfParsingTerminatedException)
{
handler.EndRdf(true);
}
catch
{
handler.EndRdf(false);
throw;
}
}
示例2: LoadGraph
/// <summary>
/// Loads a Graph from the Store asynchronously
/// </summary>
/// <param name="handler">Handler to load with</param>
/// <param name="graphUri">URI of the Graph to load</param>
/// <param name="callback">Callback</param>
/// <param name="state">State to pass to the callback</param>
public override void LoadGraph(IRdfHandler handler, string graphUri, AsyncStorageCallback callback, object state)
{
try
{
HttpWebRequest request;
Dictionary<String, String> serviceParams = new Dictionary<string, string>();
Uri baseUri = null;
SparqlParameterizedString construct = new SparqlParameterizedString();
if (!graphUri.Equals(string.Empty))
{
construct.CommandText = "CONSTRUCT { ?s ?p ?o } WHERE { GRAPH @graph { ?s ?p ?o } }";
baseUri = UriFactory.Create(graphUri);
construct.SetUri("graph", baseUri);
}
else
{
construct.CommandText = "CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o }";
}
serviceParams.Add("query", construct.ToString());
request = this.CreateRequest("/sparql", MimeTypesHelper.HttpAcceptHeader, "GET", serviceParams);
Tools.HttpDebugRequest(request);
request.BeginGetResponse(r =>
{
try
{
using (HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(r))
{
Tools.HttpDebugResponse(response);
IRdfReader parser = MimeTypesHelper.GetParser(response.ContentType);
parser.Load(handler, new StreamReader(response.GetResponseStream()));
if (baseUri != null)
{
handler.StartRdf();
handler.HandleBaseUri(baseUri);
handler.EndRdf(true);
}
response.Close();
}
callback(this, new AsyncStorageCallbackArgs(AsyncStorageOperation.LoadWithHandler, handler), state);
}
catch (WebException webEx)
{
callback(this, new AsyncStorageCallbackArgs(AsyncStorageOperation.LoadWithHandler, StorageHelper.HandleHttpError(webEx, "loading a Graph from")), state);
}
catch (Exception ex)
{
callback(this, new AsyncStorageCallbackArgs(AsyncStorageOperation.LoadWithHandler, StorageHelper.HandleError(ex, "loading a Graph from")), state);
}
}, state);
}
catch (WebException webEx)
{
callback(this, new AsyncStorageCallbackArgs(AsyncStorageOperation.LoadWithHandler, StorageHelper.HandleHttpError(webEx, "loading a Graph from")), state);
}
catch (Exception ex)
{
callback(this, new AsyncStorageCallbackArgs(AsyncStorageOperation.LoadWithHandler, StorageHelper.HandleError(ex, "loading a Graph from")), state);
}
}