本文整理汇总了C#中INodeFactory.CreateVariableNode方法的典型用法代码示例。如果您正苦于以下问题:C# INodeFactory.CreateVariableNode方法的具体用法?C# INodeFactory.CreateVariableNode怎么用?C# INodeFactory.CreateVariableNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类INodeFactory
的用法示例。
在下文中一共展示了INodeFactory.CreateVariableNode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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");
}
}