本文整理汇总了C#中INodeFactory.CreateUriNode方法的典型用法代码示例。如果您正苦于以下问题:C# INodeFactory.CreateUriNode方法的具体用法?C# INodeFactory.CreateUriNode怎么用?C# INodeFactory.CreateUriNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类INodeFactory
的用法示例。
在下文中一共展示了INodeFactory.CreateUriNode方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToNode
public static INode ToNode(this EntityId entityId, INodeFactory factory)
{
if (entityId is BlankId)
{
return factory.CreateBlankNode(entityId.Uri.Authority);
}
return factory.CreateUriNode(entityId.Uri);
}
示例2: UnWrapNode
/// <summary>Converts a RomanticWeb's <see cref="Node"/> into dotNetRDF's <see cref="INode"/>.</summary>
public static INode UnWrapNode(this Node node, INodeFactory nodeFactory)
{
if (node.IsUri)
{
return nodeFactory.CreateUriNode(node.Uri);
}
if (node.IsLiteral)
{
if (node.Language != null)
{
return nodeFactory.CreateLiteralNode(node.Literal, node.Language);
}
if (node.DataType != null)
{
return nodeFactory.CreateLiteralNode(node.Literal, node.DataType);
}
return nodeFactory.CreateLiteralNode(node.Literal);
}
return nodeFactory.CreateBlankNode(node.BlankNode);
}
示例3: CopyNode
/// <summary>
/// Copies a Node using another Node Factory
/// </summary>
/// <param name="original">Node to copy</param>
/// <param name="target">Factory to copy into</param>
/// <returns></returns>
/// <remarks>
/// <para>
/// <strong>Warning:</strong> Copying Blank Nodes may lead to unforseen circumstances since no remapping of IDs between Factories is done
/// </para>
/// </remarks>
public static INode CopyNode(INode original, INodeFactory target)
{
if (ReferenceEquals(original.Graph, target)) return original;
switch (original.NodeType)
{
case NodeType.Blank:
return target.CreateBlankNode(((IBlankNode)original).InternalID);
case NodeType.GraphLiteral:
return target.CreateGraphLiteralNode(((IGraphLiteralNode)original).SubGraph);
case NodeType.Literal:
ILiteralNode lit = (ILiteralNode)original;
if (lit.DataType != null)
{
return target.CreateLiteralNode(lit.Value, lit.DataType);
}
else if (!lit.Language.Equals(String.Empty))
{
return target.CreateLiteralNode(lit.Value, lit.Language);
}
else
{
return target.CreateLiteralNode(lit.Value);
}
case NodeType.Uri:
return target.CreateUriNode(((IUriNode)original).Uri);
case NodeType.Variable:
return target.CreateVariableNode(((IVariableNode)original).VariableName);
default:
throw new RdfException("Unable to Copy '" + original.GetType().ToString() + "' Nodes between Node Factories");
}
}
示例4: TryParseNodeValue
internal static INode TryParseNodeValue(INodeFactory factory, String value)
{
try
{
if (value.StartsWith("_:"))
{
return factory.CreateBlankNode(value.Substring(2));
}
else if (value.StartsWith("<"))
{
return factory.CreateUriNode(new Uri(UnescapeValue(value.Substring(1, value.Length - 2))));
}
else
{
if (value.EndsWith("\""))
{
return factory.CreateLiteralNode(UnescapeValue(value.Substring(1, value.Length - 2)));
}
else if (value.EndsWith(">"))
{
String lit = value.Substring(1, value.LastIndexOf("^^<") - 2);
String dt = value.Substring(lit.Length + 5, value.Length - lit.Length - 6);
return factory.CreateLiteralNode(UnescapeValue(lit), new Uri(UnescapeValue(dt)));
}
else
{
String lit = value.Substring(1, value.LastIndexOf("\"@") - 1);
String lang = value.Substring(lit.Length + 3);
return factory.CreateLiteralNode(UnescapeValue(lit), UnescapeValue(lang));
}
}
}
catch (Exception ex)
{
throw new RdfParseException("Failed to parse the value '" + value + "' into a valid Node: " + ex.Message, ex);
}
}
示例5: GetNodes
/// <summary>
/// Gets the Nodes that the algorithm should generate the descriptions for
/// </summary>
/// <param name="factory">Factory to create Nodes in</param>
/// <param name="context">SPARQL Evaluation Context</param>
/// <returns></returns>
private List<INode> GetNodes(INodeFactory factory, SparqlEvaluationContext context)
{
INamespaceMapper nsmap = (context.Query != null ? context.Query.NamespaceMap : new NamespaceMapper(true));
Uri baseUri = (context.Query != null ? context.Query.BaseUri : null);
//Build a list of INodes to describe
List<INode> nodes = new List<INode>();
foreach (IToken t in context.Query.DescribeVariables)
{
switch (t.TokenType)
{
case Token.QNAME:
case Token.URI:
//Resolve Uri/QName
nodes.Add(factory.CreateUriNode(new Uri(Tools.ResolveUriOrQName(t, nsmap, baseUri))));
break;
case Token.VARIABLE:
//Get Variable Values
String var = t.Value.Substring(1);
if (context.OutputMultiset.ContainsVariable(var))
{
foreach (ISet s in context.OutputMultiset.Sets)
{
INode temp = s[var];
if (temp != null) nodes.Add(temp);
}
}
break;
default:
throw new RdfQueryException("Unexpected Token '" + t.GetType().ToString() + "' in DESCRIBE Variables list");
}
}
return nodes;
}
示例6: LoadNode
/// <summary>
/// Decodes an Object into an appropriate Node
/// </summary>
/// <param name="factory">Node Factory to use to create Node</param>
/// <param name="n">Object to convert</param>
/// <returns></returns>
private INode LoadNode(INodeFactory factory, Object n)
{
INode temp;
if (n is SqlExtendedString)
{
SqlExtendedString iri = (SqlExtendedString)n;
if (iri.IriType == SqlExtendedStringType.BNODE)
{
//Blank Node
temp = factory.CreateBlankNode(n.ToString().Substring(9));
}
else if (iri.IriType != iri.StrType)
{
//Literal
temp = factory.CreateLiteralNode(n.ToString());
}
else if (iri.IriType == SqlExtendedStringType.IRI)
{
//Uri
Uri u = new Uri(n.ToString(), UriKind.RelativeOrAbsolute);
if (!u.IsAbsoluteUri)
{
throw new RdfParseException("Virtuoso returned a URI Node which has a relative URI, unable to resolve the URI for this node");
}
temp = factory.CreateUriNode(u);
}
else
{
//Assume a Literal
temp = factory.CreateLiteralNode(n.ToString());
}
}
else if (n is SqlRdfBox)
{
SqlRdfBox lit = (SqlRdfBox)n;
if (lit.StrLang != null)
{
//Language Specified Literal
temp = factory.CreateLiteralNode(n.ToString(), lit.StrLang);
}
else if (lit.StrType != null)
{
//Data Typed Literal
temp = factory.CreateLiteralNode(n.ToString(), new Uri(lit.StrType));
}
else
{
//Literal
temp = factory.CreateLiteralNode(n.ToString());
}
}
else if (n is String)
{
String s = n.ToString();
if (s.StartsWith("nodeID://"))
{
//Blank Node
temp = factory.CreateBlankNode(s.Substring(9));
}
else
{
//Literal
temp = factory.CreateLiteralNode(s);
}
}
else if (n is Int32)
{
temp = ((Int32)n).ToLiteral(factory);
}
else if (n is Int16)
{
temp = ((Int16)n).ToLiteral(factory);
}
else if (n is Single)
{
temp = ((Single)n).ToLiteral(factory);
}
else if (n is Double)
{
temp = ((Double)n).ToLiteral(factory);
}
else if (n is Decimal)
{
temp = ((Decimal)n).ToLiteral(factory);
}
else if (n is DateTime)
{
temp = ((DateTime)n).ToLiteral(factory);
}
else if (n is TimeSpan)
{
temp = ((TimeSpan)n).ToLiteral(factory);
}
//.........这里部分代码省略.........