本文整理汇总了C#中IGraph.Retract方法的典型用法代码示例。如果您正苦于以下问题:C# IGraph.Retract方法的具体用法?C# IGraph.Retract怎么用?C# IGraph.Retract使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGraph
的用法示例。
在下文中一共展示了IGraph.Retract方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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()));
}
}
}
}
示例2: 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);
}
}
}
示例3: Reverse
public static void Reverse(IGraph graph, Uri existingProperty, Uri reverseProperty)
{
var existingTriples = graph
.GetTriplesWithPredicate(graph.CreateUriNode(existingProperty))
.ToList();
graph.Retract(existingTriples);
INode predicate = graph.CreateUriNode(reverseProperty);
foreach (var existingTriple in existingTriples)
{
graph.Assert(existingTriple.Object, predicate, existingTriple.Subject);
}
}