本文整理汇总了C#中VDS.RDF.Graph.LoadFromString方法的典型用法代码示例。如果您正苦于以下问题:C# Graph.LoadFromString方法的具体用法?C# Graph.LoadFromString怎么用?C# Graph.LoadFromString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VDS.RDF.Graph
的用法示例。
在下文中一共展示了Graph.LoadFromString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDyno
public static dynamic GetDyno(string data, bool autoquotation = true,
bool treatUri = true,
bool skipTriplesWithEmptyObject = false,
bool mindAsterisk = false,
bool useStore = false,
string defaultGraphUri = "http://test.org/defaultgraph")
{
DynamicSPARQLSpace.dotNetRDF.Connector connector = null;
if (useStore)
{
var store = new VDS.RDF.TripleStore();
store.LoadFromString(data);
connector = new Connector(new InMemoryDataset(store, new Uri(defaultGraphUri)));
}
else
{
var graph = new VDS.RDF.Graph();
graph.LoadFromString(data);
connector = new Connector(new InMemoryDataset(graph));
}
dynamic dyno = DynamicSPARQL.CreateDyno(connector.GetQueryingFunction(),
updateFunc: connector.GetUpdateFunction(),
autoquotation: autoquotation,
treatUri: treatUri,
skipTriplesWithEmptyObject:skipTriplesWithEmptyObject,
mindAsterisk:mindAsterisk);
return dyno;
}
示例2: LoadFromString
/// <summary>Loads data from string with optional automated graph generation.</summary>
/// <param name="store">Target store to be loaded with data.</param>
/// <param name="data">String with data.</param>
/// <param name="parser">RDF reader.</param>
/// <param name="metaGraphUri">When provided, store will have automatically created graphs for all resources that are mentioned in the meta graph provided.</param>
public static void LoadFromString(this ITripleStore store, string data, IRdfReader parser, Uri metaGraphUri)
{
ITripleStore targetStore = (metaGraphUri != null ? new TripleStore() : store);
IGraph graph = new Graph();
targetStore.Add(graph);
graph.LoadFromString(data, parser);
if (metaGraphUri != null)
{
store.ExpandGraphs((TripleStore)targetStore, metaGraphUri);
}
}
示例3: CompareResultGraphs
private void CompareResultGraphs(string results, string expectedResultsPath, bool reduced)
{
var expectedResultGraph = new Graph();
FileLoader.Load(expectedResultGraph, expectedResultsPath);
var resultSet = expectedResultGraph.GetUriNode(new Uri("http://www.w3.org/2001/sw/DataAccess/tests/result-set#ResultSet"));
if (resultSet != null)
{
var rdfParser = new SparqlRdfParser();
var xmlParser = new SparqlXmlParser();
var actualResultSet = new SparqlResultSet();
var expectedResultSet = new SparqlResultSet();
using (var tr = new StringReader(results))
{
xmlParser.Load(actualResultSet, tr);
}
rdfParser.Load(expectedResultSet, expectedResultsPath);
var bnodeMap = new Dictionary<string, string>();
CompareSparqlResults(actualResultSet, expectedResultSet, reduced, bnodeMap);
}
else
{
// This is a constructed graph
var actualGraph = new Graph();
actualGraph.LoadFromString(results);
CompareTripleCollections(actualGraph.Triples, expectedResultGraph.Triples, reduced);
}
}
示例4: CompareResultGraphs
private void CompareResultGraphs(string results, string expectedResultsPath, bool reduced)
{
var expectedResultGraph = new Graph();
FileLoader.Load(expectedResultGraph, expectedResultsPath);
var resultSet = expectedResultGraph.GetUriNode(new Uri("http://www.w3.org/2001/sw/DataAccess/tests/result-set#ResultSet"));
if (resultSet != null)
{
var rdfParser = new SparqlRdfParser();
var xmlParser = new SparqlXmlParser();
var actualResultSet = new SparqlResultSet();
var expectedResultSet = new SparqlResultSet();
using (var tr = new StringReader(results))
{
xmlParser.Load(actualResultSet, tr);
}
rdfParser.Load(expectedResultSet, expectedResultsPath);
var bnodeMap = new Dictionary<string, string>();
CompareSparqlResults(actualResultSet, expectedResultSet, reduced, bnodeMap);
}
else
{
// This is a constructed graph
var actualGraph = new Graph();
actualGraph.LoadFromString(results);
var toReplace = actualGraph.Triples.Where(
t => IsGenid(t.Subject) || IsGenid(t.Predicate) || IsGenid(t.Object)).ToList();
foreach (var t in toReplace)
{
var mapped = MapGenidToBlank(t);
actualGraph.Retract(t);
actualGraph.Assert(mapped);
}
CompareTripleCollections(actualGraph.Triples, expectedResultGraph.Triples, reduced);
}
}
示例5: WritingRdfXmlWithDtds
public void WritingRdfXmlWithDtds()
{
String fragment = "@prefix xsd: <" + NamespaceMapper.XMLSCHEMA + ">. @prefix : <http://example.org/>. :subj a :obj ; :has \"string\"^^xsd:string ; :has 23 .";
Graph g = new Graph();
g.LoadFromString(fragment);
this.CheckRoundTrip(g);
}
示例6: WritingRdfXmlSimpleCollection
public void WritingRdfXmlSimpleCollection()
{
String fragment = "@prefix : <http://example.org/>. :subj :pred ( 1 2 3 ).";
Graph g = new Graph();
g.LoadFromString(fragment);
this.CheckRoundTrip(g);
}
示例7: WritingRdfXmlSimpleBNodeCollection3
public void WritingRdfXmlSimpleBNodeCollection3()
{
String fragment = "@prefix : <http://example.org/>. :subj :pred [ a :BNode ; :another :thing ].";
Graph g = new Graph();
g.LoadFromString(fragment);
this.CheckRoundTrip(g);
}