本文整理汇总了C#中Graph.SaveToFile方法的典型用法代码示例。如果您正苦于以下问题:C# Graph.SaveToFile方法的具体用法?C# Graph.SaveToFile怎么用?C# Graph.SaveToFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graph
的用法示例。
在下文中一共展示了Graph.SaveToFile方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnsureTestData
private void EnsureTestData()
{
if (!System.IO.File.Exists("temp.ttl"))
{
Graph g = new Graph();
EmbeddedResourceLoader.Load(g, "VDS.RDF.Configuration.configuration.ttl");
g.SaveToFile("temp.ttl");
}
}
示例2: EnsureTestData
private void EnsureTestData(String testFile)
{
if (!File.Exists(testFile))
{
Graph g = new Graph();
g.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl");
g.SaveToFile(testFile);
}
}
示例3: ParsingUsingCountHandler
private void ParsingUsingCountHandler(String tempFile, IRdfReader parser)
{
Graph g = new Graph();
EmbeddedResourceLoader.Load(g, "VDS.RDF.Configuration.configuration.ttl");
g.SaveToFile(tempFile);
CountHandler handler = new CountHandler();
parser.Load(handler, tempFile);
Console.WriteLine("Counted " + handler.Count + " Triples");
Assert.AreEqual(g.Triples.Count, handler.Count, "Counts should have been equal");
}
示例4: ParsingUsingWriteThroughHandler
private void ParsingUsingWriteThroughHandler(Type formatterType)
{
if (!System.IO.File.Exists("temp.ttl"))
{
Graph g = new Graph();
EmbeddedResourceLoader.Load(g, "VDS.RDF.Configuration.configuration.ttl");
g.SaveToFile("temp.ttl");
}
WriteThroughHandler handler = new WriteThroughHandler(formatterType, Console.Out, false);
TurtleParser parser = new TurtleParser();
parser.Load(handler, "temp.ttl");
}
示例5: ParsingUsingPagingHandler2
public void ParsingUsingPagingHandler2(String tempFile, IRdfReader parser)
{
Graph g = new Graph();
EmbeddedResourceLoader.Load(g, "VDS.RDF.Configuration.configuration.ttl");
g.SaveToFile(tempFile);
Graph h = new Graph();
PagingHandler handler = new PagingHandler(new GraphHandler(h), 0);
parser.Load(handler, tempFile);
Assert.IsTrue(h.IsEmpty, "Graph should be empty");
}
示例6: ParsingStringReaderEncoding
public void ParsingStringReaderEncoding()
{
String test = "<http://example.org/subject> <http://example.org/predicate> \"" + (char)32769 + "\" . ";
TurtleParser parser = new TurtleParser();
Graph g = new Graph();
parser.Load(g, new StringReader(test));
g.SaveToFile("encoding.ttl");
Graph h = new Graph();
parser.Load(h, "encoding.ttl");
Assert.AreEqual(g, h);
}
示例7: ParsingUsingPagingHandler3
public void ParsingUsingPagingHandler3(String tempFile, IRdfReader parser)
{
Graph g = new Graph();
EmbeddedResourceLoader.Load(g, "VDS.RDF.Configuration.configuration.ttl");
g.SaveToFile(tempFile);
Graph h = new Graph();
PagingHandler handler = new PagingHandler(new GraphHandler(h), -1, 100);
parser.Load(handler, tempFile);
Assert.IsFalse(h.IsEmpty, "Graph should not be empty");
Assert.AreEqual(g.Triples.Count - 100, h.Triples.Count, "Should have 100 less triples than original graph as first 100 triples are skipped");
}
示例8: ParsingUsingPagingHandler
public void ParsingUsingPagingHandler(String tempFile, IRdfReader parser)
{
Graph g = new Graph();
EmbeddedResourceLoader.Load(g, "VDS.RDF.Configuration.configuration.ttl");
g.SaveToFile(tempFile);
Graph h = new Graph();
PagingHandler handler = new PagingHandler(new GraphHandler(h), 25);
parser.Load(handler, tempFile);
h.Retract(h.Triples.Where(t => !t.IsGroundTriple));
NTriplesFormatter formatter = new NTriplesFormatter();
foreach (Triple t in h.Triples)
{
Console.WriteLine(t.ToString(formatter));
}
Console.WriteLine();
Assert.IsFalse(h.IsEmpty, "Graph should not be empty");
Assert.IsTrue(h.Triples.Count <= 25, "Graphs should have <= 25 Triples");
Graph i = new Graph();
handler = new PagingHandler(new GraphHandler(i), 25, 25);
parser.Load(handler, tempFile);
i.Retract(i.Triples.Where(t => !t.IsGroundTriple));
foreach (Triple t in i.Triples)
{
Console.WriteLine(t.ToString(formatter));
}
Console.WriteLine();
Assert.IsFalse(i.IsEmpty, "Graph should not be empty");
Assert.IsTrue(i.Triples.Count <= 25, "Graphs should have <= 25 Triples");
GraphDiffReport report = h.Difference(i);
Assert.IsFalse(report.AreEqual, "Graphs should not be equal");
Assert.AreEqual(i.Triples.Count, report.AddedTriples.Count(), "Should be " + i.Triples.Count + " added Triples");
Assert.AreEqual(h.Triples.Count, report.RemovedTriples.Count(), "Should be " + h.Triples.Count + " removed Triples");
}
示例9: ParsingUsingGraphHandlerExplicitTest
public void ParsingUsingGraphHandlerExplicitTest(String tempFile, IRdfReader parser, bool nsCheck)
{
Graph g = new Graph();
EmbeddedResourceLoader.Load(g, "VDS.RDF.Configuration.configuration.ttl");
g.SaveToFile(tempFile);
Graph h = new Graph();
GraphHandler handler = new GraphHandler(h);
parser.Load(handler, tempFile);
NTriplesFormatter formatter = new NTriplesFormatter();
foreach (Triple t in h.Triples)
{
Console.WriteLine(t.ToString(formatter));
}
Assert.IsFalse(g.IsEmpty, "Graph should not be empty");
Assert.IsTrue(g.NamespaceMap.HasNamespace("dnr"), "Graph should have the dnr: Namespace");
Assert.IsFalse(h.IsEmpty, "Graph should not be empty");
if (nsCheck) Assert.IsTrue(h.NamespaceMap.HasNamespace("dnr"), "Graph should have the dnr: Namespace");
Assert.AreEqual(g, h, "Graphs should be equal");
}
示例10: ParsingGraphHandlerImplicitMerging
public void ParsingGraphHandlerImplicitMerging()
{
Graph g = new Graph();
EmbeddedResourceLoader.Load(g, "VDS.RDF.Configuration.configuration.ttl");
g.SaveToFile("temp.ttl");
Graph h = new Graph();
TurtleParser parser = new TurtleParser();
parser.Load(h, "temp.ttl");
Assert.IsFalse(g.IsEmpty, "Graph should not be empty");
Assert.IsTrue(g.NamespaceMap.HasNamespace("dnr"), "Graph should have the dnr: Namespace");
Assert.IsFalse(h.IsEmpty, "Graph should not be empty");
Assert.IsTrue(h.NamespaceMap.HasNamespace("dnr"), "Graph should have the dnr: Namespace");
Assert.AreEqual(g, h, "Graphs should be equal");
parser.Load(h, "temp.ttl");
Assert.AreEqual(g.Triples.Count + 2, h.Triples.Count, "Triples count should now be 2 higher due to the merge which will have replicated the 2 triples containing Blank Nodes");
Assert.AreNotEqual(g, h, "Graphs should no longer be equal");
NTriplesFormatter formatter = new NTriplesFormatter();
foreach (Triple t in h.Triples.Where(x => !x.IsGroundTriple))
{
Console.WriteLine(t.ToString(formatter));
}
}