本文整理汇总了C#中VDS.RDF.Graph.GetTriplesWithPredicateObject方法的典型用法代码示例。如果您正苦于以下问题:C# Graph.GetTriplesWithPredicateObject方法的具体用法?C# Graph.GetTriplesWithPredicateObject怎么用?C# Graph.GetTriplesWithPredicateObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VDS.RDF.Graph
的用法示例。
在下文中一共展示了Graph.GetTriplesWithPredicateObject方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessTestDirectory
private void ProcessTestDirectory(String dir)
{
Console.WriteLine("## Processing Directory '" + dir + "'");
//First need to find the manifest file
if (File.Exists(dir + "manifest.ttl"))
{
Graph manifest = new Graph();
manifest.BaseUri = new Uri("file:///" + Path.GetFullPath(dir));
try
{
FileLoader.Load(manifest, dir + "manifest.ttl");
Console.WriteLine("Loaded Tests Manifest OK");
Console.WriteLine();
}
catch (RdfParseException parseEx)
{
this.ReportError("Manifest Parser Error for Directory '" + dir + "'", parseEx);
}
//Ensure qt and ut namespaces
manifest.NamespaceMap.AddNamespace("qt", new Uri("http://www.w3.org/2001/sw/DataAccess/tests/test-query#"));
manifest.NamespaceMap.AddNamespace("ut", new Uri("http://www.w3.org/2009/sparql/tests/test-update#"));
//Create necessary Uri Nodes
IUriNode rdfType = manifest.CreateUriNode("rdf:type");
IUriNode rdfsComment = manifest.CreateUriNode("rdfs:comment");
IUriNode positiveSyntaxTest = manifest.CreateUriNode("mf:PositiveSyntaxTest");
IUriNode positiveSyntaxTest11 = manifest.CreateUriNode("mf:PositiveSyntaxTest11");
IUriNode positiveUpdateSyntaxTest = manifest.CreateUriNode("mf:PositiveUpdateSyntaxTest11");
IUriNode negativeSyntaxTest = manifest.CreateUriNode("mf:NegativeSyntaxTest");
IUriNode negativeSyntaxTest11 = manifest.CreateUriNode("mf:NegativeSyntaxTest11");
IUriNode negativeUpdateSyntaxTest = manifest.CreateUriNode("mf:NegativeUpdateSyntaxTest11");
IUriNode evaluationTest = manifest.CreateUriNode("mf:QueryEvaluationTest");
IUriNode updateEvaluationTest = manifest.CreateUriNode("ut:UpdateEvaluationTest");
IUriNode action = manifest.CreateUriNode("mf:action");
IUriNode result = manifest.CreateUriNode("mf:result");
IUriNode approval = manifest.CreateUriNode("dawgt:approval");
IUriNode approvedTest = manifest.CreateUriNode("dawgt:Approved");
IUriNode unclassifiedTest = manifest.CreateUriNode("dawgt:NotClassified");
IUriNode query = manifest.CreateUriNode("qt:query");
IUriNode data = manifest.CreateUriNode("qt:data");
IUriNode graphData = manifest.CreateUriNode("qt:graphData");
//Create SPARQL Query Parser
SparqlQueryParser queryParser = new SparqlQueryParser();
SparqlUpdateParser updateParser = new SparqlUpdateParser();
queryParser.DefaultBaseUri = (manifest.BaseUri != null ? manifest.BaseUri : manifest.NamespaceMap.GetNamespaceUri(String.Empty));
updateParser.DefaultBaseUri = manifest.NamespaceMap.GetNamespaceUri(String.Empty);
//Find all the Positive Syntax Tests
foreach (Triple t in manifest.GetTriplesWithPredicateObject(rdfType, positiveSyntaxTest).Concat(manifest.GetTriplesWithPredicateObject(rdfType, positiveSyntaxTest11)).Concat(manifest.GetTriplesWithPredicateObject(rdfType, positiveUpdateSyntaxTest)))
{
//Test ID
INode testID = t.Subject;
//See whether the Test is approved
if (manifest.Triples.Contains(new Triple(testID, approval, approvedTest)) || manifest.Triples.Contains(new Triple(testID, approval, unclassifiedTest)))
{
tests++;
testsSyntax++;
//Find the Test Query
Triple queryDef = manifest.Triples.WithSubjectPredicate(testID, action).FirstOrDefault();
if (queryDef != null)
{
this.ProcessSyntaxTest(queryParser, updateParser, queryDef.Object.ToString(), true);
}
else
{
Console.WriteLine("Unable to find the Test Query/Update for Syntax Test ID '" + testID.ToString() + "' in '" + dir + "'");
testsIndeterminate++;
testsSyntaxIndeterminate++;
}
Debug.WriteLine(tests + " Tests Completed");
}
}
//Find all the Negative Syntax Tests
foreach (Triple t in manifest.GetTriplesWithPredicateObject(rdfType, negativeSyntaxTest).Concat(manifest.GetTriplesWithPredicateObject(rdfType, negativeSyntaxTest11)).Concat(manifest.GetTriplesWithPredicateObject(rdfType, negativeUpdateSyntaxTest)))
{
//Test ID
INode testID = t.Subject;
//See whether the Test is approved
if (manifest.Triples.Contains(new Triple(testID, approval, approvedTest)) || manifest.Triples.Contains(new Triple(testID, approval, unclassifiedTest)))
{
tests++;
testsSyntax++;
//Find the Test Query
Triple queryDef = manifest.Triples.WithSubjectPredicate(testID, action).FirstOrDefault();
if (queryDef != null)
{
this.ProcessSyntaxTest(queryParser, updateParser, queryDef.Object.ToString(), false);
}
else
{
//.........这里部分代码省略.........
示例2: RunDeploy
//.........这里部分代码省略.........
Console.Error.WriteLine("rdfWebDeploy: Error: Unable to continue deployment as the configuration file " + args[2] + " could not be found either locally for deployment to the App_Data folder or already present in the App_Data folder");
return;
}
//Set the AppSetting for the configuration file
config.AppSettings.Settings.Remove("dotNetRDFConfig");
config.AppSettings.Settings.Add("dotNetRDFConfig", "~/App_Data/" + Path.GetFileName(args[2]));
Console.WriteLine("rdfWebDeploy: Set the \"dotNetRDFConfig\" appSetting to \"~/App_Data/" + Path.GetFileName(args[2]) + "\"");
//Now load the Configuration Graph from the App_Data folder
Graph g = new Graph();
FileLoader.Load(g, Path.Combine(appDataFolder, args[2]));
Console.WriteLine("rdfWebDeploy: Successfully deployed required DLLs and appSettings");
Console.WriteLine();
//Get the sections of the Configuration File we want to edit
HttpHandlersSection handlersSection = config.GetSection("system.web/httpHandlers") as HttpHandlersSection;
if (handlersSection == null)
{
Console.Error.WriteLine("rdfWebDeploy: Error: Unable to access the Handlers section of the web applications Web.Config file");
return;
}
//Detect Handlers from the Configution Graph and deploy
IUriNode rdfType = g.CreateUriNode(new Uri(RdfSpecsHelper.RdfType));
IUriNode dnrType = g.CreateUriNode(new Uri(ConfigurationLoader.ConfigurationNamespace + "type"));
IUriNode httpHandler = g.CreateUriNode(new Uri(ConfigurationLoader.ConfigurationNamespace + "HttpHandler"));
//Deploy for IIS Classic Mode
if (!this._noClassicRegistration)
{
Console.WriteLine("rdfWebDeploy: Attempting deployment for IIS Classic Mode");
foreach (INode n in g.GetTriplesWithPredicateObject(rdfType, httpHandler).Select(t => t.Subject))
{
if (n.NodeType == NodeType.Uri)
{
String handlerPath = ((IUriNode)n).Uri.AbsolutePath;
INode type = g.GetTriplesWithSubjectPredicate(n, dnrType).Select(t => t.Object).FirstOrDefault();
if (type == null)
{
Console.Error.WriteLine("rdfWebDeploy: Error: Cannot deploy the Handler <" + n.ToString() + "> as there is no dnr:type property specified");
continue;
}
if (type.NodeType == NodeType.Literal)
{
String handlerType = ((ILiteralNode)type).Value;
//First remove any existing registration
handlersSection.Handlers.Remove("*", handlerPath);
//Then add the new registration
handlersSection.Handlers.Add(new HttpHandlerAction(handlerPath, handlerType, "*"));
Console.WriteLine("rdfWebDeploy: Deployed the Handler <" + n.ToString() + "> to the web applications Web.Config file");
}
else
{
Console.Error.WriteLine("rdfWebDeploy: Error: Cannot deploy the Handler <" + n.ToString() + "> as the value given for the dnr:type property is not a Literal");
continue;
}
}
else
{
Console.Error.WriteLine("rdfWebDeploy: Error: Cannot deploy a Handler which is not specified as a URI Node");
}
示例3: RunXmlDeploy
//.........这里部分代码省略.........
XmlElement systemWeb;
if (systemWebNodes.Count == 0)
{
systemWeb = config.CreateElement("system.web");
config.DocumentElement.AppendChild(systemWeb);
}
else if (systemWebNodes.Count > 1)
{
Console.Error.WriteLine("rdfWebDeploy: Error: The Configuration File for the Web Application appears to be invalid as more than one <system.web> node exists");
return;
}
else
{
systemWeb = (XmlElement)systemWebNodes[0];
}
XmlNodeList httpHandlersNodes = systemWeb.GetElementsByTagName("httpHandlers");
XmlElement httpHandlers;
if (httpHandlersNodes.Count == 0)
{
httpHandlers = config.CreateElement("httpHandlers");
systemWeb.AppendChild(httpHandlers);
}
else if (httpHandlersNodes.Count > 1)
{
Console.Error.WriteLine("rdfWebDeploy: Error: The Configuration File for the Web Application appears to be invalid as more than one <httpHandlers> node exists");
return;
}
else
{
httpHandlers = (XmlElement)httpHandlersNodes[0];
}
foreach (INode n in g.GetTriplesWithPredicateObject(rdfType, httpHandlerType).Select(t => t.Subject))
{
if (n.NodeType == NodeType.Uri)
{
String handlerPath = ((IUriNode)n).Uri.AbsolutePath;
INode type = g.GetTriplesWithSubjectPredicate(n, dnrType).Select(t => t.Object).FirstOrDefault();
if (type == null)
{
Console.Error.WriteLine("rdfWebDeploy: Error: Cannot deploy the Handler <" + n.ToString() + "> as there is no dnr:type property specified");
continue;
}
if (type.NodeType == NodeType.Literal)
{
String handlerType = ((ILiteralNode)type).Value;
//Add XML to register the Handler
reg = null;
foreach (XmlNode existingReg in httpHandlers.ChildNodes)
{
if (existingReg.Attributes.GetNamedItem("path") != null)
{
if (existingReg.Attributes["path"].Value.Equals(handlerPath))
{
reg = existingReg;
break;
}
}
}
if (reg == null)
{
reg = config.CreateElement("add");
XmlAttribute attr = config.CreateAttribute("path");
attr.Value = handlerPath;