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


C# Graph.LoadFromEmbeddedResource方法代码示例

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


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

示例1: RunTest

        public void RunTest(String[] args)
        {
            if (args.Length < 2)
            {
                Console.Error.WriteLine("rdfWebDeploy: Error: 2 Arguments are required in order to use the -test mode");
                return;
            }

            if (!File.Exists(args[1]))
            {
                Console.Error.WriteLine("rdfWebDeploy: Error: Cannot test " + args[1] + " since the file does not exist");
                return;
            }

            Graph g = new Graph();
            try
            {
                FileLoader.Load(g, args[1]);
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine("rdfWebDeploy: Error: Cannot parse the configuration file");
                Console.Error.WriteLine("rdfWebDeploy: Error: " + ex.Message);
                return;
            }
            Console.WriteLine("rdfWebDeploy: Opened the configuration file successfully");

            Graph vocab = new Graph();
            try
            {
                vocab.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl");
                vocab.LoadFromEmbeddedResource("VDS.RDF.Query.FullText.ttl, dotNetRDF.Query.FullText");
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine("rdfWebDeploy: Error: Cannot parse the configuration vocabulary");
                Console.Error.WriteLine("rdfWebDeploy: Error: " + ex.Message);
                return;
            }
            Console.WriteLine("rdfWebDeploy: Loaded the configuration vocabulary successfully");
            Console.WriteLine();
            Console.WriteLine("rdfWebDeploy: Tests Started...");
            Console.WriteLine();

            //Now make some tests against it
            int warnings = 0, errors = 0;
            IInMemoryQueryableStore store = new TripleStore();
            store.Add(vocab);
            if (g.BaseUri == null) g.BaseUri = new Uri("dotnetrdf:config");
            store.Add(g);
            Object results;
            SparqlResultSet rset;

            //Unknown vocabulary term test
            Console.WriteLine("rdfWebDeploy: Testing for URIs in the vocabulary namespace which are unknown");
            results = store.ExecuteQuery(RdfWebDeployHelper.NamespacePrefixes + UnknownVocabularyTermsTest);
            if (results is SparqlResultSet)
            {
                rset = (SparqlResultSet)results;
                foreach (SparqlResult r in rset)
                {
                    Console.Error.WriteLine("rdfWebDeploy: Error: The configuration file uses the URI '" + r["term"] + "' for a property/type and this does not appear to be a valid term in the Configuration vocabulary");
                    errors++;
                }
            }
            Console.WriteLine();

            #region General dnr:type Tests

            //Missing dnr:type test
            Console.WriteLine("rdfWebDeploy: Testing for missing dnr:type properties");
            results = g.ExecuteQuery(RdfWebDeployHelper.NamespacePrefixes + MissingConfigurationTypeTest);
            if (results is SparqlResultSet)
            {
                rset = (SparqlResultSet)results;
                foreach (SparqlResult r in rset)
                {
                    Console.Error.WriteLine("rdfWebDeploy: Warning: The Node '" + r["s"].ToString() + "' has an rdf:type but no dnr:type which may be needed by the Configuration Loader");
                    warnings++;
                }
            }
            Console.WriteLine();

            //Invalid dnr:type test
            Console.WriteLine("rdfWebDeploy: Testing that values given for dnr:type property are literals");
            results = g.ExecuteQuery(RdfWebDeployHelper.NamespacePrefixes + InvalidTypePropertyTest);
            if (results is SparqlResultSet)
            {
                rset = (SparqlResultSet)results;
                foreach (SparqlResult r in rset)
                {
                    Console.Error.WriteLine("rdfWebDeploy: Error: The node '" + r["s"].ToString() + "' has a dnr:type of '" + r["type"].ToString() + "' which is not given as a string literal");
                    errors++;
                }
            }
            Console.WriteLine();

            //Multiple dnr:type test
            Console.WriteLine("rdfWebDeploy: Testing that no object has multiple dnr:type values");
            results = g.ExecuteQuery(RdfWebDeployHelper.NamespacePrefixes + MultipleTypeTest);
//.........这里部分代码省略.........
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:101,代码来源:Test.cs


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