当前位置: 首页>>代码示例>>C#>>正文


C# Graph.GetTriplesWithPredicate方法代码示例

本文整理汇总了C#中VDS.RDF.Graph.GetTriplesWithPredicate方法的典型用法代码示例。如果您正苦于以下问题:C# Graph.GetTriplesWithPredicate方法的具体用法?C# Graph.GetTriplesWithPredicate怎么用?C# Graph.GetTriplesWithPredicate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在VDS.RDF.Graph的用法示例。


在下文中一共展示了Graph.GetTriplesWithPredicate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcessIncludes

 private static void ProcessIncludes(Graph g)
 {
     var includeTriple =
         g.GetTriplesWithPredicate(new Uri("http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#include")).
             FirstOrDefault();
     while(includeTriple != null) {
         if (includeTriple.Object.NodeType == NodeType.Blank)
         {
             ProcessList(includeTriple.Object, g, ProcessInclude);
         }
         else
         {
             ProcessInclude(includeTriple.Object, g);
         }
         g.Retract(includeTriple);
         includeTriple = g.GetTriplesWithPredicate(new Uri("http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#include")).
             FirstOrDefault();
     }
 }
开发者ID:GTuritto,项目名称:BrightstarDB,代码行数:19,代码来源:TestManifest.cs

示例2: Main

        public static void Main(String[] args)
        {
            StreamWriter output  = new StreamWriter("AllegroGraphTest.txt");
            Console.SetOut(output);
            try
            {
                Console.WriteLine("## AllegroGraph Test");
                Console.WriteLine();

                //Load the Graph we want to use as a Test
                Graph g = new Graph();
                TurtleParser ttlparser = new TurtleParser();
                ttlparser.Load(g, "InferenceTest.ttl");
                Console.WriteLine("Test Graph contains the following Triples:");
                ShowGraph(g);
                Console.WriteLine();

                //Load another Graph
                Graph h = new Graph();
                h.BaseUri = new Uri("http://example.org/test");
                Notation3Parser n3parser = new Notation3Parser();
                n3parser.Load(h, "test.n3");
                Console.WriteLine("Second Test Graph contains the following Triples:");
                ShowGraph(h);
                Console.WriteLine();

                Console.WriteLine("Trying to create a test store in the test catalog");
                AllegroGraphConnector agraph = new AllegroGraphConnector("http://localhost:9875/", "test", "test");
                Console.WriteLine("Store Created OK");
                Console.WriteLine();

                Console.WriteLine("Trying to add data to the Store");
                agraph.SaveGraph(g);
                agraph.SaveGraph(h);
                Console.WriteLine("Saved OK");
                Console.WriteLine();

                Console.WriteLine("Trying to load data from the Store");
                Graph i = new Graph();
                agraph.LoadGraph(i, String.Empty);
                ShowGraph(i);
                Console.WriteLine();
                i = new Graph();
                agraph.LoadGraph(i, new Uri("http://example.org/test"));
                ShowGraph(i);
                Console.WriteLine("Loaded OK");
                Console.WriteLine();

                Console.WriteLine("Trying to update data in the Store");
                List<Triple> toRemove = g.GetTriplesWithPredicate(g.CreateUriNode("rdf:type")).ToList();
                Triple toAdd = new Triple(g.CreateUriNode(new Uri("http://example.org/")), g.CreateUriNode("rdf:type"), g.CreateLiteralNode("Added Triple Test"));
                agraph.UpdateGraph(String.Empty, new List<Triple>() { toAdd }, toRemove);
                Console.WriteLine("Updated OK");
                Console.WriteLine();

                Console.WriteLine("Trying a SPARQL ASK query against the store");
                Object results = agraph.Query("ASK WHERE {?s ?p ?o}");
                Console.WriteLine("Got results OK");
                ShowResults(results);
                Console.WriteLine();

                Console.WriteLine("Trying a SPARQL SELECT query against the store");
                results = agraph.Query("SELECT * WHERE {?s ?p ?o}");
                Console.WriteLine("Got results OK");
                ShowResults(results);
                Console.WriteLine();

            }
            catch (RdfStorageException storeEx)
            {
                reportError(output, "RDF Storage Error", storeEx);
            }
            catch (RdfParseException parseEx)
            {
                reportError(output, "RDF Parsing Error", parseEx);
            }
            catch (RdfQueryException queryEx)
            {
                reportError(output, "RDF Query Error", queryEx);
            }
            catch (RdfException rdfEx)
            {
                reportError(output, "RDF Error", rdfEx);
            }
            catch (WebException webEx)
            {
                reportError(output, "HTTP Error", webEx);
            }
            catch (Exception ex)
            {
                reportError(output, "Error", ex);
            }
            finally
            {
                output.Close();
            }
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:97,代码来源:AllegroGraphTest.cs


注:本文中的VDS.RDF.Graph.GetTriplesWithPredicate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。