本文整理汇总了C#中IGraph.ContainsTriple方法的典型用法代码示例。如果您正苦于以下问题:C# IGraph.ContainsTriple方法的具体用法?C# IGraph.ContainsTriple怎么用?C# IGraph.ContainsTriple使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGraph
的用法示例。
在下文中一共展示了IGraph.ContainsTriple方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialise
protected override void Initialise(IGraph g)
{
if (g.BaseUri != null) this._node = g.CreateUriNode();
//First ensure all the correct namespace prefixes are set to the correct URIs
g.NamespaceMap.AddNamespace("rdf", new Uri(NamespaceMapper.RDF));
g.NamespaceMap.AddNamespace("void", new Uri(VoIDNamespace));
g.NamespaceMap.AddNamespace("foaf", new Uri(FoafNamespace));
g.NamespaceMap.AddNamespace("dcterms", new Uri(DublinCoreTermsNamespace));
g.NamespaceMap.AddNamespace("aat", new Uri(AATNamespace));
//First look for an Expansion Profile description
Triple profileDescriptor = new Triple(g.CreateUriNode(), g.CreateUriNode("rdf:type"), g.CreateUriNode("aat:ExpansionProfile"));
if (g.ContainsTriple(profileDescriptor))
{
//Does it specify a Max Expansion Depth?
Triple maxDepthSpecifier = g.GetTriplesWithSubjectPredicate(g.CreateUriNode(), g.CreateUriNode("aat:maxExpansionDepth")).FirstOrDefault();
if (maxDepthSpecifier != null)
{
if (maxDepthSpecifier.Object.NodeType == NodeType.Literal)
{
ILiteralNode l = (ILiteralNode)maxDepthSpecifier.Object;
if (l.DataType != null && l.DataType.ToString().Equals(XmlSpecsHelper.XmlSchemaDataTypeInteger))
{
this._maxDepth = Int32.Parse(l.Value);
}
}
}
}
//Find Datasets
foreach (Triple t in g.GetTriplesWithPredicateObject(g.CreateUriNode("rdf:type"), g.CreateUriNode("void:Dataset")))
{
ExpansionDataset dataset = new ExpansionDataset(g, t.Subject);
if (this._datasets.ContainsKey(t.Subject))
{
throw new NotImplementedException("Merging Expansion Datasets is not yet implemented");
}
else
{
this._datasets.Add(t.Subject, dataset);
}
}
//Find Linksets
foreach (Triple t in g.GetTriplesWithPredicateObject(g.CreateUriNode("rdf:type"), g.CreateUriNode("void:Linkset")))
{
ExpansionLinkset linkset = new ExpansionLinkset(g, t.Subject);
if (this._linksets.ContainsKey(t.Subject))
{
throw new NotImplementedException("Merging Expansion Linksets is not yet implemented");
}
else
{
this._linksets.Add(t.Subject, linkset);
}
}
}
示例2: TemplateToEnumerable
/// <summary>
/// Converts a SemWeb Statement Template to an IEnumerable of Triples
/// </summary>
/// <param name="template">Statement Template</param>
/// <param name="g">Graph the Template should be created for</param>
/// <returns></returns>
private IEnumerable<Triple> TemplateToEnumerable(Statement template, IGraph g)
{
INode s, p, o;
int hash;
if (g.BaseUri == null)
{
hash = new Uri(GraphCollection.DefaultGraphUri).GetEnhancedHashCode();
}
else
{
hash = g.BaseUri.GetEnhancedHashCode();
}
if (template.Subject is Variable)
{
if (template.Predicate is Variable)
{
if (template.Object is Variable)
{
//All three things are variables so this just checks that some Triple(s) are present
return g.Triples;
}
else
{
//Subject & Predicate are Variables
//Convert the Object and do a WithObject().Any() call
o = SemWebConverter.FromSemWeb(template.Object, this.GetMapping(hash, g));
return g.GetTriplesWithObject(o);
}
}
else if (template.Object is Variable)
{
//Subject & Object are variables
//Convert the Predicate and do a WithPredicate() call
p = SemWebConverter.FromSemWeb(template.Predicate, this.GetMapping(hash, g));
return g.GetTriplesWithPredicate(p);
}
else
{
//Subject is a Variable
//Convert the Predicate and Object and do a WithPredicateObject() call
p = SemWebConverter.FromSemWeb(template.Predicate, this.GetMapping(hash, g));
o = SemWebConverter.FromSemWeb(template.Object, this.GetMapping(hash, g));
return g.GetTriplesWithPredicateObject(p, o);
}
}
else if (template.Predicate is Variable)
{
if (template.Object is Variable)
{
//Predicate & Object are Variables
//Convert the Subject and do a WithSubject() call
s = SemWebConverter.FromSemWeb(template.Subject, this.GetMapping(hash, g));
return g.GetTriplesWithSubject(s);
}
else
{
//Predicate is a Variable
//Convert the Subject and Object and do a WithSubjectObject() call
s = SemWebConverter.FromSemWeb(template.Subject, this.GetMapping(hash, g));
o = SemWebConverter.FromSemWeb(template.Object, this.GetMapping(hash, g));
return g.GetTriplesWithSubjectObject(s, o);
}
}
else if (template.Object is Variable)
{
//Object is a Variable
//Convert the Subject and Predicate and do a WithSubjectPredicate() call
s = SemWebConverter.FromSemWeb(template.Subject, this.GetMapping(hash, g));
p = SemWebConverter.FromSemWeb(template.Predicate, this.GetMapping(hash, g));
return g.GetTriplesWithSubjectPredicate(s, p);
}
else
{
//Just convert the Triple and do a Contains() call
Triple t = SemWebConverter.FromSemWeb(template, this.GetMapping(hash, g));
if (g.ContainsTriple(t))
{
return t.AsEnumerable();
}
else
{
return Enumerable.Empty<Triple>();
}
}
}
示例3: IsDelete
static bool IsDelete(INode subject, IGraph graph)
{
return graph.ContainsTriple(new Triple(subject, graph.CreateUriNode(Schema.Predicates.Type), graph.CreateUriNode(Schema.DataTypes.CatalogDelete)))
|| graph.ContainsTriple(new Triple(subject, graph.CreateUriNode(Schema.Predicates.Type), graph.CreateUriNode(Schema.DataTypes.PackageDelete)));
}