本文整理汇总了C#中VDS.RDF.Graph.CreateUriNode方法的典型用法代码示例。如果您正苦于以下问题:C# Graph.CreateUriNode方法的具体用法?C# Graph.CreateUriNode怎么用?C# Graph.CreateUriNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VDS.RDF.Graph
的用法示例。
在下文中一共展示了Graph.CreateUriNode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: fclsGraphBrowser
public fclsGraphBrowser()
{
InitializeComponent();
//Connect to Virtuoso
this._manager = new VirtuosoManager(Properties.Settings.Default.Server, Properties.Settings.Default.Port, VirtuosoQuadStoreDB, Properties.Settings.Default.Username, Properties.Settings.Default.Password);
//Add some fake test data
DataTable data = new DataTable();
data.Columns.Add("Subject");
data.Columns.Add("Predicate");
data.Columns.Add("Object");
data.Columns["Subject"].DataType = typeof(INode);
data.Columns["Predicate"].DataType = typeof(INode);
data.Columns["Object"].DataType = typeof(INode);
Graph g = new Graph();
DataRow row = data.NewRow();
row["Subject"] = g.CreateUriNode(new Uri("http://example.org/subject"));
row["Predicate"] = g.CreateUriNode(new Uri("http://example.org/predicate"));
row["Object"] = g.CreateUriNode(new Uri("http://example.org/object"));
data.Rows.Add(row);
this.BindGraph(data);
}
示例2: Main
public static void Main(String[] args)
{
//Fill in the code shown on this page here to build your hello world application
Graph g = new Graph();
IUriNode dotNetRDF = g.CreateUriNode(new Uri("http://www.dotnetrdf.org"));
IUriNode says = g.CreateUriNode(new Uri("http://example.org/says"));
ILiteralNode helloWorld = g.CreateLiteralNode("Hello World");
ILiteralNode bonjourMonde = g.CreateLiteralNode("Bonjour tout le Monde", "fr");
g.Assert(new Triple(dotNetRDF, says, helloWorld));
g.Assert(new Triple(dotNetRDF, says, bonjourMonde));
foreach (Triple t in g.Triples)
{
Console.WriteLine(t.ToString());
}
NTriplesWriter ntwriter = new NTriplesWriter();
ntwriter.Save(g, "HelloWorld.nt");
RdfXmlWriter rdfxmlwriter = new RdfXmlWriter();
rdfxmlwriter.Save(g, "HelloWorld.rdf");
}
示例3: ReplaceResourceUris
public static IGraph ReplaceResourceUris(IGraph original, IDictionary<string, Uri> replacements)
{
IGraph modified = new Graph();
foreach (Triple triple in original.Triples)
{
Uri subjectUri;
if (!replacements.TryGetValue(triple.Subject.ToString(), out subjectUri))
{
subjectUri = ((IUriNode)triple.Subject).Uri;
}
INode subjectNode = modified.CreateUriNode(subjectUri);
INode predicateNode = triple.Predicate.CopyNode(modified);
INode objectNode;
if (triple.Object is IUriNode)
{
Uri objectUri;
if (!replacements.TryGetValue(triple.Object.ToString(), out objectUri))
{
objectUri = ((IUriNode)triple.Object).Uri;
}
objectNode = modified.CreateUriNode(objectUri);
}
else
{
objectNode = triple.Object.CopyNode(modified);
}
modified.Assert(subjectNode, predicateNode, objectNode);
}
return modified;
}
示例4: TestCreateEntryFeedForSingleItem
public void TestCreateEntryFeedForSingleItem()
{
var testGraph = new Graph {BaseUri = new Uri("http://dbpedia.org/resource/")};
var film = testGraph.CreateUriNode(UriFactory.Create("http://dbpedia.org/resource/Un_Chien_Andalou"));
testGraph.Assert(film,
testGraph.CreateUriNode(UriFactory.Create("http://www.w3.org/1999/02/22-rdf-syntax-ns#type")),
testGraph.CreateUriNode(UriFactory.Create("http://dbpedia.org/ontology/Film")));
testGraph.Assert(film,
testGraph.CreateUriNode(UriFactory.Create("http://xmlns.com/foaf/0.1/name")),
testGraph.CreateLiteralNode("Un Chien Andalou"));
var mockRequest = new Mock<IODataRequestMessage>();
mockRequest.Setup(m => m.Url).Returns(new Uri("http://example.org/odata/Films('Un_Chien_Andalou')"));
var mock = new Mock<IODataResponseMessage>();
var mockStream = new MemoryStream();
//mock.Setup(m => m.Url).Returns(new Uri("http://example.org/odata/Films('Un_Chien_Andalou')"));
//mock.Setup(m => m.Method).Returns("GET");
mock.Setup(m => m.GetStream()).Returns(mockStream);
var generator = new ODataFeedGenerator(mockRequest.Object, mock.Object, _dbpediaMap, "http://example.org/odata/", new ODataMessageWriterSettings{Indent = true});
generator.CreateEntryFromGraph(testGraph, film.Uri.ToString(), "DBPedia.Film");
mockStream.Seek(0, SeekOrigin.Begin);
var streamXml = XDocument.Load(mockStream);
Assert.IsNotNull(streamXml);
Assert.IsNotNull(streamXml.Root);
Assert.AreEqual(XName.Get("entry", "http://www.w3.org/2005/Atom"), streamXml.Root.Name);
Console.WriteLine(streamXml.ToString());
XNamespace atom = "http://www.w3.org/2005/Atom";
Assert.AreEqual("http://example.org/odata/Films('Un_Chien_Andalou')",
(string)streamXml.Root.Element(atom+"id"));
}
示例5: WritingBlankNodeOutput
public void WritingBlankNodeOutput()
{
//Create a Graph and add a couple of Triples which when serialized have
//potentially colliding IDs
Graph g = new Graph();
g.NamespaceMap.AddNamespace("ex", new Uri("http://example.org"));
IUriNode subj = g.CreateUriNode("ex:subject");
IUriNode pred = g.CreateUriNode("ex:predicate");
IUriNode name = g.CreateUriNode("ex:name");
IBlankNode b1 = g.CreateBlankNode("autos1");
IBlankNode b2 = g.CreateBlankNode("1");
g.Assert(subj, pred, b1);
g.Assert(b1, name, g.CreateLiteralNode("First Triple"));
g.Assert(subj, pred, b2);
g.Assert(b2, name, g.CreateLiteralNode("Second Triple"));
TurtleWriter ttlwriter = new TurtleWriter();
ttlwriter.Save(g, "bnode-output-test.ttl");
TestTools.ShowGraph(g);
TurtleParser ttlparser = new TurtleParser();
Graph h = new Graph();
ttlparser.Load(h, "bnode-output-test.ttl");
TestTools.ShowGraph(h);
Assert.AreEqual(g.Triples.Count, h.Triples.Count, "Expected same number of Triples after serialization and reparsing");
}
示例6: Execute
public override bool Execute(PipelinePackage package, PackagePipelineContext context)
{
DateTime? commitTimeStamp = PackagePipelineHelpers.GetCommitTimeStamp(context);
Guid? commitId = PackagePipelineHelpers.GetCommitId(context);
IGraph graph = new Graph();
INode resource = graph.CreateUriNode(context.Uri);
if (commitTimeStamp != null)
{
graph.Assert(
resource,
graph.CreateUriNode(Schema.Predicates.CatalogTimeStamp),
graph.CreateLiteralNode(commitTimeStamp.Value.ToString("O"), Schema.DataTypes.DateTime));
}
if (commitId != null)
{
graph.Assert(
resource,
graph.CreateUriNode(Schema.Predicates.CatalogCommitId),
graph.CreateLiteralNode(commitId.Value.ToString()));
}
context.StageResults.Add(new GraphPackageMetadata(graph));
return true;
}
示例7: WritingRdfXmlLiteralsWithLanguageTags
public void WritingRdfXmlLiteralsWithLanguageTags()
{
Graph g = new Graph();
INode s = g.CreateUriNode(new Uri("http://example.org/subject"));
INode p = g.CreateUriNode(new Uri("http://example.org/predicate"));
INode o = g.CreateLiteralNode("string", "en");
g.Assert(s, p, o);
this.CheckRoundTrip(g);
}
示例8: insertLearningObject
/// <summary>
///
/// </summary>
/// <param name="g"></param>
/// <param name="LO"></param>
public void insertLearningObject(ref Graph g, LearningObjectContextModel LO)
{
g.NamespaceMap.AddNamespace("onto", new Uri("http://www.owl-ontologies.com/OntoAdapt2.owl#"));
IUriNode sujeito = g.CreateUriNode("onto:" + LO.LearningObject_ID);
INode rdfType = g.CreateUriNode("rdf:type");
INode objeto = g.CreateUriNode("onto:LearningObject");
Triple triple = new Triple(sujeito, rdfType, objeto);
g.Assert(triple);
}
示例9: CreateContent
public string CreateContent(CatalogContext context)
{
IGraph graph = new Graph();
graph.NamespaceMap.AddNamespace("rdf", new Uri("http://www.w3.org/1999/02/22-rdf-syntax-ns#"));
graph.NamespaceMap.AddNamespace("catalog", new Uri("http://nuget.org/catalog#"));
INode rdfTypePredicate = graph.CreateUriNode("rdf:type");
INode timeStampPredicate = graph.CreateUriNode("catalog:timeStamp");
Uri dateTimeDatatype = new Uri("http://www.w3.org/2001/XMLSchema#dateTime");
INode container = graph.CreateUriNode(_resourceUri);
graph.Assert(container, rdfTypePredicate, graph.CreateUriNode(GetContainerType()));
graph.Assert(container, timeStampPredicate, graph.CreateLiteralNode(_timeStamp.ToString(), dateTimeDatatype));
if (_parent != null)
{
graph.Assert(container, graph.CreateUriNode("catalog:parent"), graph.CreateUriNode(_parent));
}
AddCustomContent(container, graph);
INode itemPredicate = graph.CreateUriNode("catalog:item");
INode countPredicate = graph.CreateUriNode("catalog:count");
foreach (KeyValuePair<Uri, Tuple<Uri, IGraph, DateTime, int?>> item in GetItems())
{
INode itemNode = graph.CreateUriNode(item.Key);
graph.Assert(container, itemPredicate, itemNode);
graph.Assert(itemNode, rdfTypePredicate, graph.CreateUriNode(item.Value.Item1));
if (item.Value.Item2 != null)
{
graph.Merge(item.Value.Item2);
}
graph.Assert(itemNode, timeStampPredicate, graph.CreateLiteralNode(item.Value.Item3.ToString(), dateTimeDatatype));
if (item.Value.Item4 != null)
{
Uri integerDatatype = new Uri("http://www.w3.org/2001/XMLSchema#integer");
graph.Assert(itemNode, countPredicate, graph.CreateLiteralNode(item.Value.Item4.ToString(), integerDatatype));
}
}
JObject frame = context.GetJsonLdContext("context.Container.json", GetContainerType());
string content = Utils.CreateJson(graph, frame);
return content;
}
示例10: insertComunidadeMoodle
/// <summary>
///
/// </summary>
/// <param name="g"></param>
public void insertComunidadeMoodle(ref Graph g)
{
g = new Graph();
g.NamespaceMap.AddNamespace("onto", new Uri("http://www.owl-ontologies.com/OntoAdapt2.owl#"));
IUriNode sujeito = g.CreateUriNode("onto:" + student.Matricula);
INode rdfType = g.CreateUriNode("onto:ComunidadeMoodle");
ILiteralNode literal = g.CreateLiteralNode(student.ComunidadeMoodle);
Triple triple = new Triple(sujeito, rdfType, literal);
g.Assert(triple);
}
示例11: insertLearningObjectComunidade
/// <summary>
/// Insere LO a comunidade
/// </summary>
/// <param name="g"></param>
/// <param name="LO"></param>
public void insertLearningObjectComunidade(ref Graph g, LearningObjectContextModel LO)
{
g = new Graph();
g.NamespaceMap.AddNamespace("onto", new Uri("http://www.owl-ontologies.com/OntoAdapt2.owl#"));
IUriNode sujeito = g.CreateUriNode("onto:" + LO.LearningObject_ID);
INode rdfType = g.CreateUriNode("onto:LO_MoodleCommunity");
ILiteralNode objeto = g.CreateLiteralNode(LO.MoodleCommunity);
Triple triple = new Triple(sujeito, rdfType, objeto);
g.Assert(triple);
}
示例12: InsertDeviceBrand
/// <summary>
///
/// </summary>
/// <param name="g"></param>
public void InsertDeviceBrand(ref Graph g)
{
g = new Graph();
g.NamespaceMap.AddNamespace("onto", new Uri("http://www.owl-ontologies.com/OntoAdapt2.owl#"));
IUriNode sujeito = g.CreateUriNode("onto:" + Device.model_name);
INode rdfType = g.CreateUriNode("onto:Brand");
ILiteralNode literal = g.CreateLiteralNode(Device.Brand_Name);
Triple triple = new Triple(sujeito, rdfType, literal);
g.Assert(triple);
}
示例13: insertDeviceMediaPreference
/// <summary>
///
/// </summary>
/// <param name="g"></param>
/// <param name="strLearningStyle"></param>
public void insertDeviceMediaPreference(ref Graph g)
{
g = new Graph();
g.NamespaceMap.AddNamespace("onto", new Uri("http://www.owl-ontologies.com/OntoAdapt2.owl#"));
IUriNode sujeito = g.CreateUriNode("onto:" + Device.model_name);
INode rdfType = g.CreateUriNode("onto:hasDeviceMediaPreference");
IUriNode objeto = g.CreateUriNode(new Uri("http://www.owl-ontologies.com/OntoAdapt2.owl#" + Device.MediaPreference));
Triple triple = new Triple(sujeito, rdfType, objeto);
g.Assert(triple);
}
示例14: AddTripleLiteral
/// <summary>
/// Adds the literal triple to a graph.
/// </summary>
/// <param name="graph">The graph.</param>
/// <param name="subject">The subject.</param>
/// <param name="predicate">The predicate.</param>
/// <param name="obj">The object (resource).</param>
/// <remarks></remarks>
public static void AddTripleLiteral(Graph graph, string subject, string predicate, string obj, string datatype)
{
string xmlSchemaDatatype;
switch (datatype)
{
case "Url":
xmlSchemaDatatype = XmlSpecsHelper.XmlSchemaDataTypeAnyUri;
break;
case "Date":
xmlSchemaDatatype = XmlSpecsHelper.XmlSchemaDataTypeDateTime;
break;
case "Integer":
xmlSchemaDatatype = XmlSpecsHelper.XmlSchemaDataTypeInteger;
break;
case "Ntext":
xmlSchemaDatatype = XmlSpecsHelper.XmlSchemaDataTypeString;
break;
case "Nvarchar":
xmlSchemaDatatype = XmlSpecsHelper.XmlSchemaDataTypeString;
break;
default:
xmlSchemaDatatype = XmlSpecsHelper.XmlSchemaDataTypeString;
break;
}
Triple triple = null;
if (subject.StartsWith("http") && predicate.StartsWith("http"))
{
triple = new Triple(
graph.CreateUriNode(new Uri(subject)),
graph.CreateUriNode(new Uri(predicate)),
graph.CreateLiteralNode(obj, new Uri(xmlSchemaDatatype))
);
}
else if (!subject.StartsWith("http") && predicate.StartsWith("http"))
{
triple = new Triple(
graph.CreateUriNode(subject),
graph.CreateUriNode(new Uri(predicate)),
graph.CreateLiteralNode(obj, new Uri(xmlSchemaDatatype))
);
}
else if (subject.StartsWith("http") && !predicate.StartsWith("http"))
{
triple = new Triple(
graph.CreateUriNode(new Uri(subject)),
graph.CreateUriNode(predicate),
graph.CreateLiteralNode(obj, new Uri(xmlSchemaDatatype))
);
}
else if (!subject.StartsWith("http") && !predicate.StartsWith("http"))
{
triple = new Triple(
graph.CreateUriNode(subject),
graph.CreateUriNode(predicate),
graph.CreateLiteralNode(obj, new Uri(xmlSchemaDatatype))
);
}
graph.Assert(triple);
}
示例15: CreateCommitMetadata
public static IGraph CreateCommitMetadata(Uri indexUri, DateTime? lastCreated, DateTime? lastEdited)
{
IGraph graph = new Graph();
if (lastCreated != null)
{
graph.Assert(graph.CreateUriNode(indexUri), graph.CreateUriNode(Schema.Predicates.LastCreated), graph.CreateLiteralNode(lastCreated.Value.ToString("O"), Schema.DataTypes.DateTime));
}
if (lastEdited != null)
{
graph.Assert(graph.CreateUriNode(indexUri), graph.CreateUriNode(Schema.Predicates.LastEdited), graph.CreateLiteralNode(lastEdited.Value.ToString("O"), Schema.DataTypes.DateTime));
}
return graph;
}