本文整理汇总了C#中IRdfHandler.Apply方法的典型用法代码示例。如果您正苦于以下问题:C# IRdfHandler.Apply方法的具体用法?C# IRdfHandler.Apply怎么用?C# IRdfHandler.Apply使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRdfHandler
的用法示例。
在下文中一共展示了IRdfHandler.Apply方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadGraph
/// <summary>
/// Loads a Graph from the Dataset with the given Handler
/// </summary>
/// <param name="handler">RDF Handler</param>
/// <param name="graphUri">URI of the Graph to load</param>
public void LoadGraph(IRdfHandler handler, Uri graphUri)
{
IGraph g = null;
if (graphUri == null)
{
if (this._store.HasGraph(graphUri))
{
g = this._store.Graph(graphUri);
}
else
{
foreach (Uri u in WriterHelper.StoreDefaultGraphURIs.Select(s => new Uri(s)))
{
if (this._store.HasGraph(u))
{
g = this._store.Graph(u);
break;
}
}
}
}
else if (this._store.HasGraph(graphUri))
{
g = this._store.Graph(graphUri);
}
handler.Apply(g);
}
示例2: Query
/// <summary>
/// Processes a SPARQL Query against the Knowledge Base passing the results to the RDF or Results handler as appropriate
/// </summary>
/// <param name="rdfHandler">RDF Handler</param>
/// <param name="resultsHandler">Results Handler</param>
/// <param name="sparqlQuery">SPARQL Query</param>
/// <param name="callback">Callback to invoke once handling of results has completed</param>
/// <param name="state">State to pass to the callback</param>
public void Query(IRdfHandler rdfHandler, ISparqlResultsHandler resultsHandler, String sparqlQuery, QueryCallback callback, Object state)
{
SparqlQueryParser parser = new SparqlQueryParser();
SparqlQuery q = parser.ParseFromString(sparqlQuery);
SparqlRemoteEndpoint endpoint = new SparqlRemoteEndpoint(UriFactory.Create(this._sparqlUri));
switch (q.QueryType)
{
case SparqlQueryType.Ask:
case SparqlQueryType.Select:
case SparqlQueryType.SelectAll:
case SparqlQueryType.SelectAllDistinct:
case SparqlQueryType.SelectAllReduced:
case SparqlQueryType.SelectDistinct:
case SparqlQueryType.SelectReduced:
endpoint.QueryWithResultSet(sparqlQuery, (rs, _) =>
{
resultsHandler.Apply(rs);
callback(rdfHandler, resultsHandler, state);
}, state);
break;
case SparqlQueryType.Construct:
case SparqlQueryType.Describe:
case SparqlQueryType.DescribeAll:
endpoint.QueryWithResultGraph(sparqlQuery, (g, _) =>
{
rdfHandler.Apply(g);
callback(rdfHandler, resultsHandler, state);
}, state);
break;
default:
throw new RdfQueryException("Cannot execute unknown query types against Pellet Server");
}
}
示例3: LoadGraph
/// <summary>
/// Loads a Graph from the Store
/// </summary>
/// <param name="handler">RDF Handler</param>
/// <param name="graphUri">Graph URI to load</param>
public void LoadGraph(IRdfHandler handler, Uri graphUri)
{
IGraph g = null;
if (this._dataset.HasGraph(graphUri))
{
g = this._dataset[graphUri];
}
handler.Apply(g);
}
示例4: LoadGraph
/// <summary>
/// Loads a Graph from the Store using the given RDF Handler
/// </summary>
/// <param name="handler">RDF Handler</param>
/// <param name="graphUri">URI of the Graph to load</param>
public virtual void LoadGraph(IRdfHandler handler, Uri graphUri)
{
try
{
this.Open(true);
if (this.Exists(graphUri))
{
//Load into an Empty Graph and then Merge
IGraph g = new Graph();
//Load Namespaces and Triples
String graphID = this.GetGraphID(graphUri);
this.LoadNamespaces(g, graphID);
this.LoadTriples(g, graphID);
handler.Apply(g);
}
else
{
handler.Apply((IGraph)null);
}
this.Close(true);
}
catch
{
this.Close(true, true);
throw;
}
}