本文整理汇总了C#中IGraph.CreateUriNode方法的典型用法代码示例。如果您正苦于以下问题:C# IGraph.CreateUriNode方法的具体用法?C# IGraph.CreateUriNode怎么用?C# IGraph.CreateUriNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGraph
的用法示例。
在下文中一共展示了IGraph.CreateUriNode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
}
}
示例2: 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;
}
示例3: GetPackageRegistrationUri
public static Uri GetPackageRegistrationUri(IGraph graph)
{
return ((IUriNode)graph.GetTriplesWithPredicateObject(
graph.CreateUriNode(new Uri("http://www.w3.org/1999/02/22-rdf-syntax-ns#type")),
graph.CreateUriNode(new Uri("http://schema.nuget.org/schema#PackageRegistration")))
.First().Subject).Uri;
}
示例4: 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);
}
示例5: 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);
}
}
}
示例6: ApplyToGraph
/// <summary>
/// Add data from nuget.packed.json
/// </summary>
public override void ApplyToGraph(IGraph graph, IUriNode mainNode)
{
Uri mainUri = mainNode.Uri;
IUriNode typeNode = graph.CreateUriNode(Schema.Predicates.Type);
// supported frameworks
if (SupportedFrameworks != null)
{
foreach (string framework in SupportedFrameworks)
{
graph.Assert(new Triple(mainNode, graph.CreateUriNode(Schema.Predicates.SupportedFramework), graph.CreateLiteralNode(framework)));
}
}
// assets
//if (AssetGroups != null)
//{
// int groupId = 0;
// foreach (var group in AssetGroups)
// {
// // group type and id
// var groupNode = GetSubNode(graph, mainUri, "assetGroup", "" + groupId);
// graph.Assert(groupNode, typeNode, graph.CreateUriNode(PackageAssetGroupType));
// graph.Assert(mainNode, graph.CreateUriNode(AssetGroupPredicate), groupNode);
// groupId++;
// int propId = 0;
// // group properties
// foreach (var prop in group.Properties)
// {
// var propNode = GetSubNode(graph, groupNode, "property", "" + propId);
// propId++;
// graph.Assert(propNode, typeNode, graph.CreateUriNode(PackageAssetGroupPropertyType));
// graph.Assert(groupNode, graph.CreateUriNode(AssetGroupPropertyPredicate), propNode);
// graph.Assert(propNode, graph.CreateUriNode(AssetKeyPredicate), graph.CreateLiteralNode(prop.Key));
// graph.Assert(propNode, graph.CreateUriNode(AssetValuePredicate), graph.CreateLiteralNode(prop.Value));
// }
// int assetId = 0;
// // group items
// foreach (var item in group.Items)
// {
// var itemNode = GetSubNode(graph, groupNode, "asset", "" + assetId);
// assetId++;
// graph.Assert(itemNode, typeNode, graph.CreateUriNode(PackageAssetType));
// graph.Assert(groupNode, graph.CreateUriNode(AssetPredicate), itemNode);
// graph.Assert(itemNode, graph.CreateUriNode(AssetTypePredicate), graph.CreateLiteralNode(item.ArtifactType));
// graph.Assert(itemNode, graph.CreateUriNode(AssetPathPredicate), graph.CreateLiteralNode(item.Path));
// }
// }
//}
}
示例7: 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;
}
示例8: 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);
}
示例9: GetStats
public void GetStats(IGraph g)
{
g.NamespaceMap.AddNamespace("opt", new Uri(SparqlOptimiser.OptimiserStatsNamespace));
INode subjectCount = g.CreateUriNode("opt:subjectCount");
INode predicateCount = g.CreateUriNode("opt:predicateCount");
INode objectCount = g.CreateUriNode("opt:objectCount");
INode count = g.CreateUriNode("opt:count");
this.AddStats(g, this.NodeCounts, count);
this.AddStats(g, this.ObjectCounts, objectCount);
this.AddStats(g, this.PredicateCounts, predicateCount);
this.AddStats(g, this.SubjectCounts, subjectCount);
}
示例10: 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()));
}
}
}
}
示例11: OpenConnectionForm
/// <summary>
/// Creates a new Open Connection Form
/// </summary>
/// <param name="g">Graph contaning Connection Definitions</param>
public OpenConnectionForm(IGraph g)
{
InitializeComponent();
//Find connections defined in the Configuration Graph
this._g = g;
INode genericManager = ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.ClassGenericManager);
INode rdfsLabel = g.CreateUriNode(new Uri(NamespaceMapper.RDFS + "label"));
SparqlParameterizedString getConnections = new SparqlParameterizedString();
getConnections.QueryText = "SELECT ?obj ?label WHERE { ?obj a @type . OPTIONAL { ?obj @label ?label } } ORDER BY ?label";
getConnections.SetParameter("type", genericManager);
getConnections.SetParameter("label", rdfsLabel);
Object results = this._g.ExecuteQuery(getConnections.ToString());
if (results is SparqlResultSet)
{
SparqlResultSet rset = (SparqlResultSet)results;
foreach (SparqlResult r in rset)
{
this._connectionNodes.Add(r["obj"]);
if (r.HasValue("label"))
{
this.lstConnections.Items.Add(r["label"]);
}
else
{
this.lstConnections.Items.Add(r["obj"]);
}
}
}
}
示例12: 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);
}
}
}
示例13: 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;
}
示例14: ReplaceIRI
public static void ReplaceIRI(IGraph graph, Uri oldIRI, Uri newIRI)
{
// replace the local IRI with the NuGet IRI
string localUri = oldIRI.AbsoluteUri;
var triples = graph.Triples.ToArray();
string mainIRI = newIRI.AbsoluteUri;
foreach (var triple in triples)
{
IUriNode subject = triple.Subject as IUriNode;
IUriNode objNode = triple.Object as IUriNode;
INode newSubject = triple.Subject;
INode newObject = triple.Object;
bool replace = false;
if (subject != null && subject.Uri.AbsoluteUri.StartsWith(localUri))
{
// TODO: store these mappings in a dictionary
Uri iri = new Uri(String.Format(CultureInfo.InvariantCulture, "{0}{1}", mainIRI, subject.Uri.AbsoluteUri.Substring(localUri.Length)));
newSubject = graph.CreateUriNode(iri);
replace = true;
}
if (objNode != null && objNode.Uri.AbsoluteUri.StartsWith(localUri))
{
// TODO: store these mappings in a dictionary
Uri iri = new Uri(String.Format(CultureInfo.InvariantCulture, "{0}{1}", mainIRI, objNode.Uri.AbsoluteUri.Substring(localUri.Length)));
newObject = graph.CreateUriNode(iri);
replace = true;
}
if (replace)
{
graph.Assert(newSubject, triple.Predicate, newObject);
graph.Retract(triple);
}
}
}
示例15: 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));
}