本文整理汇总了C#中Graph.ContainsTriple方法的典型用法代码示例。如果您正苦于以下问题:C# Graph.ContainsTriple方法的具体用法?C# Graph.ContainsTriple怎么用?C# Graph.ContainsTriple使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graph
的用法示例。
在下文中一共展示了Graph.ContainsTriple方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StorageFourStoreAddTriples
public void StorageFourStoreAddTriples()
{
StorageFourStoreDeleteGraph();
StorageFourStoreSaveGraph();
Graph g = new Graph();
List<Triple> ts = new List<Triple>();
ts.Add(new Triple(g.CreateUriNode(new Uri("http://example.org/subject")), g.CreateUriNode(new Uri("http://example.org/predicate")), g.CreateUriNode(new Uri("http://example.org/object"))));
FourStoreConnector fourstore = new FourStoreConnector(FourStoreTestUri);
fourstore.UpdateGraph("http://example.org/4storeTest", ts, null);
fourstore.LoadGraph(g, "http://example.org/4storeTest");
Assert.IsTrue(ts.All(t => g.ContainsTriple(t)), "Added Triple should not have been in the Graph");
}
示例2: SparqlUpdateDeleteDataCombination
public void SparqlUpdateDeleteDataCombination()
{
SparqlParameterizedString command = new SparqlParameterizedString();
command.Namespaces.AddNamespace("ex", new Uri("http://example.org/"));
command.CommandText = "DELETE DATA { ex:a ex:b ex:c GRAPH <http://example.org/graph> { ex:a ex:b ex:c } }";
SparqlUpdateParser parser = new SparqlUpdateParser();
SparqlUpdateCommandSet cmds = parser.ParseFromString(command);
Assert.IsFalse(cmds.Commands.All(cmd => cmd.AffectsSingleGraph), "Commands should report that they do not affect a single Graph");
Assert.IsTrue(cmds.Commands.All(cmd => cmd.AffectsGraph(null)), "Commands should report that they affect the Default Graph");
Assert.IsTrue(cmds.Commands.All(cmd => cmd.AffectsGraph(new Uri("http://example.org/graph"))), "Commands should report that they affect the named Graph");
InMemoryDataset dataset = new InMemoryDataset();
IGraph def = new Graph();
def.NamespaceMap.Import(command.Namespaces);
def.Assert(new Triple(def.CreateUriNode("ex:a"), def.CreateUriNode("ex:b"), def.CreateUriNode("ex:c")));
dataset.AddGraph(def);
IGraph ex = new Graph();
ex.BaseUri = new Uri("http://example.org/graph");
ex.NamespaceMap.Import(command.Namespaces);
ex.Assert(new Triple(ex.CreateUriNode("ex:a"), ex.CreateUriNode("ex:b"), ex.CreateUriNode("ex:c")));
dataset.AddGraph(ex);
LeviathanUpdateProcessor processor = new LeviathanUpdateProcessor(dataset);
processor.ProcessCommandSet(cmds);
Graph g = new Graph();
g.NamespaceMap.Import(command.Namespaces);
Triple t = new Triple(g.CreateUriNode("ex:a"), g.CreateUriNode("ex:b"), g.CreateUriNode("ex:c"));
def = dataset[null];
Assert.AreEqual(0, def.Triples.Count, "Should be 0 Triples in the Default Graph");
Assert.IsFalse(def.ContainsTriple(t), "Should not have the deleted Triple in the Default Graph");
ex = dataset[new Uri("http://example.org/graph")];
Assert.AreEqual(0, ex.Triples.Count, "Should be 0 Triples in the Named Graph");
Assert.IsFalse(ex.ContainsTriple(t), "Should not have the deleted Triple in the Named Graph");
}
示例3: TestWriteToStoreDatasetsHandler
private void TestWriteToStoreDatasetsHandler(IGenericIOManager manager)
{
NodeFactory factory = new NodeFactory();
INode a = factory.CreateUriNode(new Uri("http://example.org/a"));
INode b = factory.CreateUriNode(new Uri("http://example.org/b"));
INode c = factory.CreateUriNode(new Uri("http://example.org/c"));
INode d = factory.CreateUriNode(new Uri("http://example.org/d"));
Uri graphB = new Uri("http://example.org/graphs/b");
Uri graphD = new Uri("http://example.org/graphs/d");
//Try to ensure that the target Graphs do not exist
if (manager.DeleteSupported)
{
manager.DeleteGraph(TestGraphUri);
manager.DeleteGraph(graphB);
manager.DeleteGraph(graphD);
}
else
{
Graph g = new Graph();
g.BaseUri = TestGraphUri;
manager.SaveGraph(g);
g.BaseUri = graphB;
manager.SaveGraph(g);
g.BaseUri = graphD;
manager.SaveGraph(g);
}
//Do the parsing and thus the loading
WriteToStoreHandler handler = new WriteToStoreHandler(manager, TestGraphUri);
NQuadsParser parser = new NQuadsParser();
parser.Load(handler, new StreamParams("writetostore.nq"));
//Load the expected Graphs
Graph def = new Graph();
manager.LoadGraph(def, TestGraphUri);
Graph gB = new Graph();
manager.LoadGraph(gB, graphB);
Graph gD = new Graph();
manager.LoadGraph(gD, graphD);
Assert.AreEqual(2, def.Triples.Count, "Should be two triples in the default Graph");
Assert.IsTrue(def.ContainsTriple(new Triple(a, a, a)), "Default Graph should have the a triple");
Assert.AreEqual(1, gB.Triples.Count, "Should be one triple in the b Graph");
Assert.IsTrue(gB.ContainsTriple(new Triple(b, b, b)), "b Graph should have the b triple");
Assert.IsTrue(def.ContainsTriple(new Triple(c, c, c)), "Default Graph should have the c triple");
Assert.AreEqual(1, gD.Triples.Count, "Should be one triple in the d Graph");
Assert.IsTrue(gD.ContainsTriple(new Triple(d, d, d)), "d Graph should have the d triple");
}
示例4: StorageFusekiRemoveTriples
public void StorageFusekiRemoveTriples()
{
try
{
Options.UriLoaderCaching = false;
StorageFusekiSaveGraph();
Graph g = new Graph();
List<Triple> ts = new List<Triple>();
ts.Add(new Triple(g.CreateUriNode(new Uri("http://example.org/subject")), g.CreateUriNode(new Uri("http://example.org/predicate")), g.CreateUriNode(new Uri("http://example.org/object"))));
FusekiConnector fuseki = new FusekiConnector(FusekiTestUri);
fuseki.UpdateGraph("http://example.org/fusekiTest", null, ts);
fuseki.LoadGraph(g, "http://example.org/fusekiTest");
Assert.IsTrue(ts.All(t => !g.ContainsTriple(t)), "Removed Triple should not have been in the Graph");
}
finally
{
Options.UriLoaderCaching = true;
}
}