本文整理汇总了C#中IGraph.GetTriplesWithSubjectPredicate方法的典型用法代码示例。如果您正苦于以下问题:C# IGraph.GetTriplesWithSubjectPredicate方法的具体用法?C# IGraph.GetTriplesWithSubjectPredicate怎么用?C# IGraph.GetTriplesWithSubjectPredicate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGraph
的用法示例。
在下文中一共展示了IGraph.GetTriplesWithSubjectPredicate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetLists
private static IDictionary<INode, List<INode>> GetLists(IGraph graph)
{
INode first = graph.CreateUriNode(new Uri(First));
INode rest = graph.CreateUriNode(new Uri(Rest));
INode nil = graph.CreateUriNode(new Uri(Nil));
IDictionary<INode, List<INode>> lists = new Dictionary<INode, List<INode>>();
IEnumerable<Triple> ends = graph.GetTriplesWithPredicateObject(rest, nil);
foreach (Triple end in ends)
{
List<INode> list = new List<INode>();
Triple iterator = graph.GetTriplesWithSubjectPredicate(end.Subject, first).First();
INode head = iterator.Subject;
while (true)
{
list.Add(iterator.Object);
IEnumerable<Triple> restTriples = graph.GetTriplesWithPredicateObject(rest, iterator.Subject);
if (!restTriples.Any())
{
break;
}
iterator = graph.GetTriplesWithSubjectPredicate(restTriples.First().Subject, first).First();
head = iterator.Subject;
}
list.Reverse();
lists.Add(head, list);
}
return lists;
}
示例2: ExpansionDataset
public ExpansionDataset(IGraph expansionDescription, INode datasetSubj)
: base(expansionDescription, datasetSubj)
{
//Check for aat:ignoreDataset
IEnumerable<Triple> ts = expansionDescription.GetTriplesWithSubjectPredicate(datasetSubj, expansionDescription.CreateUriNode("aat:ignoreDataset"));
Triple t = ts.FirstOrDefault();
if (t != null)
{
if (t.Object.NodeType == NodeType.Literal)
{
ILiteralNode l = (ILiteralNode)t.Object;
if (l.DataType != null && l.DataType.ToString().Equals(XmlSpecsHelper.XmlSchemaDataTypeBoolean))
{
this._ignore = Boolean.Parse(l.Value);
}
}
}
//Find URI Discovery Endpoints
ts = expansionDescription.GetTriplesWithSubjectPredicate(datasetSubj, expansionDescription.CreateUriNode("aat:uriDiscoveryEndpoint"));
foreach (Triple endpoint in ts)
{
if (endpoint.Object.NodeType == NodeType.Uri)
{
this._discoveryEndpoints.Add(((IUriNode)endpoint.Object).Uri);
}
}
}
示例3: VoIDDataset
public VoIDDataset(IGraph voidDescription, INode datasetSubj)
{
this._subj = datasetSubj;
IEnumerable<Triple> ts;
Triple t;
//Get Title, Description and Homepage (if present)
ts = voidDescription.GetTriplesWithSubjectPredicate(datasetSubj, voidDescription.CreateUriNode("dcterms:title"));
t = ts.FirstOrDefault();
if (t != null)
{
if (t.Object.NodeType == NodeType.Literal)
{
this._title = ((ILiteralNode)t.Object).Value;
}
}
ts = voidDescription.GetTriplesWithSubjectPredicate(datasetSubj, voidDescription.CreateUriNode("dcterms:description"));
t = ts.FirstOrDefault();
if (t != null)
{
if (t.Object.NodeType == NodeType.Literal)
{
this._description = ((ILiteralNode)t.Object).Value;
}
}
ts = voidDescription.GetTriplesWithSubjectPredicate(datasetSubj, voidDescription.CreateUriNode("foaf:homepage"));
t = ts.FirstOrDefault();
if (t != null)
{
if (t.Object.NodeType == NodeType.Uri)
{
this._homepage = ((IUriNode)t.Object).Uri;
}
}
//Find SPARQL Endpoints
ts = voidDescription.GetTriplesWithSubjectPredicate(datasetSubj, voidDescription.CreateUriNode("void:sparqlEndpoint"));
foreach (Triple endpoint in ts)
{
if (endpoint.Object.NodeType == NodeType.Uri)
{
this._sparqlEndpoints.Add(((IUriNode)endpoint.Object).Uri);
}
}
//Find URI Lookup Endpoints
ts = voidDescription.GetTriplesWithSubjectPredicate(datasetSubj, voidDescription.CreateUriNode("void:uriLookupEndpoint"));
foreach (Triple endpoint in ts)
{
if (endpoint.Object.NodeType == NodeType.Uri)
{
this._lookupEndpoints.Add(((IUriNode)endpoint.Object).Uri);
}
}
}
示例4: CreatePageGraph
IGraph CreatePageGraph(INode subject, IGraph graph)
{
Graph pageGraph = new Graph();
Triple idTriple = graph.GetTriplesWithSubjectPredicate(subject, graph.CreateUriNode(Schema.Predicates.Id)).First();
Triple versionTriple = graph.GetTriplesWithSubjectPredicate(subject, graph.CreateUriNode(Schema.Predicates.Version)).First();
pageGraph.Assert(idTriple.CopyTriple(pageGraph));
pageGraph.Assert(versionTriple.CopyTriple(pageGraph));
return pageGraph;
}
示例5: Promote
public static RegistrationKey Promote(string resourceUri, IGraph graph)
{
INode subject = graph.CreateUriNode(new Uri(resourceUri));
string id = graph.GetTriplesWithSubjectPredicate(subject, graph.CreateUriNode(Schema.Predicates.Id)).First().Object.ToString();
return new RegistrationKey(id);
}
示例6: Replace
private void Replace(IGraph graph, IUriNode parent, Uri predicate, string jsonField)
{
JToken token = null;
if (_galleryPage.TryGetValue(jsonField, out token))
{
JArray array = token as JArray;
JValue val = token as JValue;
if (array != null || val != null)
{
var pred = graph.CreateUriNode(predicate);
var old = graph.GetTriplesWithSubjectPredicate(parent, pred).ToArray();
// remove the old values
foreach (var triple in old)
{
graph.Retract(triple);
}
if (array != null)
{
foreach (var child in array)
{
graph.Assert(parent, pred, graph.CreateLiteralNode(child.ToString()));
}
}
else
{
graph.Assert(parent, pred, graph.CreateLiteralNode(val.ToString()));
}
}
}
}
示例7: IsListed
static bool IsListed(INode subject, IGraph graph)
{
//return graph.ContainsTriple(new Triple(subject, graph.CreateUriNode(Schema.Predicates.Listed), graph.CreateLiteralNode("true", Schema.DataTypes.Boolean)));
Triple listed = graph.GetTriplesWithSubjectPredicate(subject, graph.CreateUriNode(Schema.Predicates.Listed)).FirstOrDefault();
if (listed != null)
{
return ((ILiteralNode)listed.Object).Value.Equals("true", StringComparison.InvariantCultureIgnoreCase);
}
Triple published = graph.GetTriplesWithSubjectPredicate(subject, graph.CreateUriNode(Schema.Predicates.Published)).FirstOrDefault();
if (published != null)
{
DateTime publishedDate = DateTime.Parse(((ILiteralNode)published.Object).Value);
return publishedDate.Year != 1900;
}
return true;
}
示例8: VoIDLinkset
public VoIDLinkset(IGraph voidDescription, INode linksetSubj)
{
IUriNode target = voidDescription.CreateUriNode("void:target");
IUriNode subjTarget = voidDescription.CreateUriNode("void:subjectsTarget");
IUriNode objTarget = voidDescription.CreateUriNode("void:objectsTarget");
IUriNode linkPredicate = voidDescription.CreateUriNode("void:linkPredicate");
if (voidDescription.GetTriplesWithSubjectPredicate(linksetSubj, target).Any())
{
IEnumerable<Triple> ts = voidDescription.GetTriplesWithSubjectPredicate(linksetSubj, target).Take(2);
this._subjectTarget = ts.First().Object;
this._objectsTarget = ts.Last().Object;
}
else
{
this._subjectTarget = voidDescription.GetTriplesWithSubjectPredicate(linksetSubj, subjTarget).First().Object;
this._objectsTarget = voidDescription.GetTriplesWithSubjectPredicate(linksetSubj, objTarget).First().Object;
this._directed = true;
}
this._predicates.AddRange(voidDescription.GetTriplesWithSubjectPredicate(linksetSubj, linkPredicate).Select(t => t.Object));
}
示例9: Promote
public static KeyValuePair<RegistrationEntryKey, RegistrationCatalogEntry> Promote(string resourceUri, IGraph graph, bool isExistingItem)
{
INode subject = graph.CreateUriNode(new Uri(resourceUri));
string version = graph.GetTriplesWithSubjectPredicate(subject, graph.CreateUriNode(Schema.Predicates.Version)).First().Object.ToString();
RegistrationEntryKey registrationEntryKey = new RegistrationEntryKey(RegistrationKey.Promote(resourceUri, graph), version);
RegistrationCatalogEntry registrationCatalogEntry = IsDelete(subject, graph)
? null
: new RegistrationCatalogEntry(resourceUri, graph, isExistingItem);
return new KeyValuePair<RegistrationEntryKey, RegistrationCatalogEntry>(registrationEntryKey, registrationCatalogEntry);
}
示例10: TryLoadObject
public bool TryLoadObject(IGraph g, INode objNode, Type targetType, out object obj)
{
if (targetType == typeof (MockStorageServer))
{
var server = new MockStorageServer();
var storeIdNode = g.CreateUriNode("http://www.dotnetrdf.org/configuration#storeId");
foreach (var t in g.GetTriplesWithSubjectPredicate(objNode, storeIdNode))
{
var lit = t.Object as ILiteralNode;
if (lit != null)
{
server.AddStore(lit.Value);
}
}
obj = server;
return true;
}
obj = null;
return false;
}
示例11: ExpansionLinkset
public ExpansionLinkset(IGraph expansionDescription, INode linksetSubj)
: base(expansionDescription, linksetSubj)
{
this._subject = linksetSubj;
//Check for aat:ignoreLinkset
IEnumerable<Triple> ts = expansionDescription.GetTriplesWithSubjectPredicate(linksetSubj, expansionDescription.CreateUriNode("aat:ignoreDataset"));
Triple t = ts.FirstOrDefault();
if (t != null)
{
if (t.Object.NodeType == NodeType.Literal)
{
ILiteralNode l = (ILiteralNode)t.Object;
if (l.DataType != null && l.DataType.ToString().Equals(XmlSpecsHelper.XmlSchemaDataTypeBoolean))
{
this._ignore = Boolean.Parse(l.Value);
}
}
}
}
示例12: SetIdVersionFromGraph
private void SetIdVersionFromGraph(IGraph graph)
{
var resource = graph.GetTriplesWithPredicateObject(
graph.CreateUriNode(Schema.Predicates.Type), graph.CreateUriNode(GetItemType())).First();
var id = graph.GetTriplesWithSubjectPredicate(
resource.Subject, graph.CreateUriNode(Schema.Predicates.Id)).FirstOrDefault();
if (id != null)
{
_id = ((ILiteralNode)id.Object).Value;
}
var version = graph.GetTriplesWithSubjectPredicate(
resource.Subject, graph.CreateUriNode(Schema.Predicates.Version)).FirstOrDefault();
if (version != null)
{
_version = ((ILiteralNode)version.Object).Value;
}
}
示例13: 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);
}
}
}
示例14: GetConfigurationInt32
/// <summary>
/// Gets the 64 bit Integer value or a given default of the first instance of a property for a given Object in the Configuration Graph
/// </summary>
/// <param name="g">Configuration Graph</param>
/// <param name="objNode">Object Node</param>
/// <param name="property">Property Node</param>
/// <param name="defValue">Default Value to return if there is no valid boolean value</param>
/// <returns>
/// If there is a valid integer value for the property then that is returned, in any other case the given <paramref name="defValue">Default Value</paramref> is returned
/// </returns>
public static int GetConfigurationInt32(IGraph g, INode objNode, INode property, int defValue)
{
INode n = g.GetTriplesWithSubjectPredicate(objNode, property).Select(t => t.Object).FirstOrDefault();
if (n == null) return defValue;
//Resolve AppSettings
if (n.NodeType != NodeType.Literal)
{
n = ResolveAppSetting(g, n);
if (n == null) return defValue;
}
if (n.NodeType == NodeType.Literal)
{
int temp;
if (Int32.TryParse(((ILiteralNode)n).Value, out temp))
{
return temp;
}
else
{
return defValue;
}
}
else
{
return defValue;
}
}
示例15: GetConfigurationValue
/// <summary>
/// Gets the String value or null of the first instance of a property for a given Object in the Configuration Graph
/// </summary>
/// <param name="g">Configuration Graph</param>
/// <param name="objNode">Object Node</param>
/// <param name="property">Property Node</param>
/// <returns></returns>
public static String GetConfigurationValue(IGraph g, INode objNode, INode property)
{
INode n = g.GetTriplesWithSubjectPredicate(objNode, property).Select(t => t.Object).FirstOrDefault();
if (n == null) return null;
switch (n.NodeType)
{
case NodeType.Blank:
return n.ToString();
case NodeType.Literal:
return ((ILiteralNode)n).Value;
case NodeType.Uri:
INode temp = ResolveAppSetting(g, n);
if (temp == null) return null;
if (temp.NodeType == NodeType.Literal)
{
return ((ILiteralNode)temp).Value;
}
else
{
return temp.ToString();
}
default:
return null;
}
}