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


C# Graph.LoadFromEmbeddedResource方法代码示例

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


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

示例1: SparqlOptimiserQueryWeightedSimple2

        public void SparqlOptimiserQueryWeightedSimple2()
        {
            try
            {
                String query = @"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT * WHERE
{
  ?s rdfs:label ?label .
  ?s rdfs:comment ?comment .
}";

                Graph weightings = new Graph();
                weightings.LoadFromEmbeddedResource("VDS.RDF.Test.Sparql.SampleWeightings.n3, dotNetRDF.Test");
                SparqlOptimiser.QueryOptimiser = new WeightedOptimiser(weightings);

                SparqlQuery q = this._parser.ParseFromString(query);

                Console.WriteLine(this._formatter.Format(q));

                Assert.IsTrue(q.RootGraphPattern.TriplePatterns[0].Variables.Contains("comment"), "First Triple Pattern should contain ?comment");
                Assert.IsTrue(q.RootGraphPattern.TriplePatterns[1].Variables.Contains("label"), "Second Triple Pattern should contain ?label");
            }
            finally
            {
                SparqlOptimiser.ResetOptimisers();
            }
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:27,代码来源:WeightedOptimiserTests.cs

示例2: StorageDydraSaveToDefaultGraph

        public void StorageDydraSaveToDefaultGraph()
        {
            try
            {
                Options.HttpDebugging = true;

                Graph orig = new Graph();
                orig.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl");
                orig.BaseUri = null;

                DydraConnector dydra = this.GetConnection();
                dydra.SaveGraph(orig);

                Graph g = new Graph();
                dydra.LoadGraph(g, (Uri)null);

                if (orig.Triples.Count == g.Triples.Count)
                {
                    Assert.AreEqual(orig, g, "Graphs should be equal");
                }
                else
                {
                    Assert.IsTrue(g.HasSubGraph(orig), "Original Graph should be a sub-graph of retrieved Graph");
                }
            }
            catch (Exception ex)
            {
                TestTools.ReportError("Error", ex, true);
            }
            finally
            {
                Options.HttpDebugging = false;
            }
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:34,代码来源:DydraTests.cs

示例3: StorageStardogSaveToDefaultGraph

        public void StorageStardogSaveToDefaultGraph()
        {
            try
            {
                //Options.UseBomForUtf8 = false;

                StardogConnector stardog = this.GetConnection();
                Graph g = new Graph();
                g.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl");
                g.BaseUri = null;
                stardog.SaveGraph(g);

                Graph h = new Graph();
                stardog.LoadGraph(h, (Uri)null);

                if (g.Triples.Count == h.Triples.Count)
                {
                    Assert.AreEqual(g, h, "Retrieved Graph should be equal to the Saved Graph");
                }
                else
                {
                    Assert.IsTrue(h.HasSubGraph(g), "Retrieved Graph should have the Saved Graph as a subgraph");
                }
            }
            finally
            {
                //Options.UseBomForUtf8 = true;
            }
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:29,代码来源:StardogTests.cs

示例4: EnsureTestData

 private void EnsureTestData(String testFile)
 {
     if (!File.Exists(testFile))
     {
         Graph g = new Graph();
         g.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl");
         g.SaveToFile(testFile);
     }
 }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:9,代码来源:FileLoaderHandlerTests.cs

示例5: ParsingUriLoaderCountHandler

        public void ParsingUriLoaderCountHandler()
        {
            Graph orig = new Graph();
            orig.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl");

            CountHandler handler = new CountHandler();
            UriLoader.Load(handler, new Uri("http://www.dotnetrdf.org/configuration#"));

            Assert.AreEqual(orig.Triples.Count, handler.Count);
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:10,代码来源:UriLoaderHandlerTests.cs

示例6: ParsingFileLoaderCountHandlerTurtle

        public void ParsingFileLoaderCountHandlerTurtle()
        {
            EnsureTestData("temp.ttl");
            Graph orig = new Graph();
            orig.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl");
            CountHandler handler = new CountHandler();
            FileLoader.Load(handler, "temp.ttl");

            Assert.AreEqual(orig.Triples.Count, handler.Count);
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:10,代码来源:FileLoaderHandlerTests.cs

示例7: EnsureTestData

        private void EnsureTestData(String file, ISparqlResultsWriter writer)
        {
            if (!File.Exists(file))
            {
                Graph g = new Graph();
                g.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl");
                SparqlResultSet results = g.ExecuteQuery("SELECT * WHERE { ?s ?p ?o }") as SparqlResultSet;
                if (results == null) Assert.Fail("Failed to generate sample SPARQL Results");

                writer.Save(results, file);
            }
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:12,代码来源:ResultSetHandlerTests.cs

示例8: EnsureTestData

        private void EnsureTestData(String testFile)
        {
            if (!File.Exists(testFile))
            {
                TripleStore store = new TripleStore();
                Graph g = new Graph();
                g.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl");
                store.Add(g);
                Graph h = new Graph();
                h.LoadFromEmbeddedResource("VDS.RDF.Query.Expressions.Functions.LeviathanFunctionLibrary.ttl");
                store.Add(h);

                store.SaveToFile(testFile);
            }
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:15,代码来源:StoreHandlerTests.cs

示例9: WritingTriGActual

        private void WritingTriGActual()
        {
            Graph g = new Graph();
            g.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl");
            g.BaseUri = null;
            TripleStore store = new TripleStore();
            store.Add(g);

            TriGWriter writer = new TriGWriter();
            System.IO.StringWriter strWriter = new System.IO.StringWriter();
            writer.Save(store, new TextWriterParams(strWriter));

            Console.WriteLine(strWriter.ToString());

            Assert.IsFalse(strWriter.ToString().Equals(String.Empty));
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:16,代码来源:TriGWriterTests.cs

示例10: WritingTriGUncompressedSingleThreaded

        public void WritingTriGUncompressedSingleThreaded()
        {
            Graph g = new Graph();
            g.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl");
            g.BaseUri = null;
            TripleStore store = new TripleStore();
            store.Add(g);

            TriGWriter writer = new TriGWriter();
            writer.UseMultiThreadedWriting = false;
            writer.CompressionLevel = WriterCompressionLevel.None;
            System.IO.StringWriter strWriter = new System.IO.StringWriter();
            writer.Save(store, new TextWriterParams(strWriter));

            Console.WriteLine(strWriter.ToString());

            Assert.IsFalse(strWriter.ToString().Equals(String.Empty));
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:18,代码来源:TriGWriterTests.cs

示例11: ParsingGraphHandlerImplicitBaseUriPropogation2

        public void ParsingGraphHandlerImplicitBaseUriPropogation2()
        {
            try
            {
                Options.UriLoaderCaching = false;

                Graph g = new Graph();
                g.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl");
                UriLoader.Load(g, new Uri("http://wiki.rkbexplorer.com/id/void"));
                NTriplesFormatter formatter = new NTriplesFormatter();
                foreach (Triple t in g.Triples)
                {
                    Console.WriteLine(t.ToString());
                }
            }
            finally
            {
                Options.UriLoaderCaching = true;
            }
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:20,代码来源:GraphHandlerTests.cs

示例12: ParsingStoreHandlerNQuadsImplicitActual

        private void ParsingStoreHandlerNQuadsImplicitActual()
        {
            this.EnsureTestData("test.nq");

            TripleStore store = new TripleStore();
            StreamParams ps = new StreamParams("test.nq", Encoding.ASCII);

            NQuadsParser parser = new NQuadsParser();
            parser.Load(store, ps);

            Assert.IsTrue(store.HasGraph(new Uri("http://www.dotnetrdf.org/configuration#")), "Configuration Vocab Graph should have been parsed from Dataset");
            Graph configOrig = new Graph();
            configOrig.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl");
            IGraph config = store.Graph(new Uri("http://www.dotnetrdf.org/configuration#"));
            Assert.AreEqual(configOrig, config, "Configuration Vocab Graphs should have been equal");

            Assert.IsTrue(store.HasGraph(new Uri("http://www.dotnetrdf.org/leviathan#")), "Leviathan Function Library Graph should have been parsed from Dataset");
            Graph lvnOrig = new Graph();
            lvnOrig.LoadFromEmbeddedResource("VDS.RDF.Query.Expressions.Functions.LeviathanFunctionLibrary.ttl");
            IGraph lvn = store.Graph(new Uri("http://www.dotnetrdf.org/leviathan#"));
            Assert.AreEqual(lvnOrig, lvn, "Leviathan Function Library Graphs should have been equal");

        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:23,代码来源:StoreHandlerTests.cs

示例13: SparqlFilterOptionalNotBound

        public void SparqlFilterOptionalNotBound()
        {
            Graph g = new Graph();
            g.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl");

            SparqlParameterizedString query = new SparqlParameterizedString();
            query.Namespaces.AddNamespace("rdf", new Uri(NamespaceMapper.RDF));
            query.Namespaces.AddNamespace("rdfs", new Uri(NamespaceMapper.RDFS));
            query.CommandText = "SELECT * WHERE { ?property a rdf:Property . OPTIONAL { ?property rdfs:range ?range } FILTER (!BOUND(?range)) }";

            SparqlQueryParser parser = new SparqlQueryParser();
            SparqlQuery q = parser.ParseFromString(query);
            SparqlResultSet results = g.ExecuteQuery(q) as SparqlResultSet;
            if (results != null)
            {
                TestTools.ShowResults(results);

                Assert.IsTrue(results.All(r => !r.HasValue("range") || r["range"] == null), "There should be no values for ?range returned");
            }
            else
            {
                Assert.Fail("Did not get a SparqlResultSet as expected");
            }
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:24,代码来源:FilterPlacementTests.cs

示例14: ParsingStoreHandlerTriXCountingActual

        private void ParsingStoreHandlerTriXCountingActual()
        {
            this.EnsureTestData("test.xml");

            StreamParams ps = new StreamParams("test.xml", Encoding.ASCII);

            TriXParser parser = new TriXParser();
            StoreCountHandler counter = new StoreCountHandler();
            parser.Load(counter, ps);

            Graph configOrig = new Graph();
            configOrig.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl");
            Graph lvnOrig = new Graph();
            lvnOrig.LoadFromEmbeddedResource("VDS.RDF.Query.Expressions.Functions.LeviathanFunctionLibrary.ttl");

            Assert.AreEqual(2, counter.GraphCount, "Expected 2 Graphs to be counted");
            Assert.AreEqual(configOrig.Triples.Count + lvnOrig.Triples.Count, counter.TripleCount, "Expected Triple Count to be sum of Triple Counts in two input Graphs");
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:18,代码来源:StoreHandlerTests.cs

示例15: ParsingFileLoaderStoreHandlerCountingActual

        private void ParsingFileLoaderStoreHandlerCountingActual()
        {
            this.EnsureTestData("test.nq");

            StoreCountHandler counter = new StoreCountHandler();
            FileLoader.LoadDataset(counter, "test.nq");

            Graph configOrig = new Graph();
            configOrig.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl");
            Graph lvnOrig = new Graph();
            lvnOrig.LoadFromEmbeddedResource("VDS.RDF.Query.Expressions.Functions.LeviathanFunctionLibrary.ttl");

            Assert.AreEqual(2, counter.GraphCount, "Expected 2 Graphs to be counted");
            Assert.AreEqual(configOrig.Triples.Count + lvnOrig.Triples.Count, counter.TripleCount, "Expected Triple Count to be sum of Triple Counts in two input Graphs");
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:15,代码来源:StoreHandlerTests.cs


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