当前位置: 首页>>代码示例>>C#>>正文


C# INodeFactory.CreateBlankNode方法代码示例

本文整理汇总了C#中INodeFactory.CreateBlankNode方法的典型用法代码示例。如果您正苦于以下问题:C# INodeFactory.CreateBlankNode方法的具体用法?C# INodeFactory.CreateBlankNode怎么用?C# INodeFactory.CreateBlankNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在INodeFactory的用法示例。


在下文中一共展示了INodeFactory.CreateBlankNode方法的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);
        }
开发者ID:rafalrosochacki,项目名称:RomanticWeb,代码行数:9,代码来源:EntityIdExtensions.cs

示例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);
        }
开发者ID:rafalrosochacki,项目名称:RomanticWeb,代码行数:25,代码来源:NodeExtensions.cs

示例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");
            }
        }
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:43,代码来源:Tools.cs

示例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);
     }
 }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:37,代码来源:JsonNTriplesParser.cs

示例5: RewriteDescribeBNodes

        //OPT: Replace with usage of MapTriple instead?

        /// <summary>
        /// Helper method which rewrites Blank Node IDs for Describe Queries
        /// </summary>
        /// <param name="t">Triple</param>
        /// <param name="mapping">Mapping of IDs to new Blank Nodes</param>
        /// <param name="factory">Factory to create Nodes in</param>
        /// <returns></returns>
        protected Triple RewriteDescribeBNodes(Triple t, Dictionary<String, INode> mapping, INodeFactory factory)
        {
            INode s, p, o;
            String id;

            if (t.Subject.NodeType == NodeType.Blank)
            {
                id = t.Subject.GetHashCode() + "-" + t.Graph.GetHashCode();
                if (mapping.ContainsKey(id))
                {
                    s = mapping[id];
                }
                else
                {
                    s = factory.CreateBlankNode(id);
                    mapping.Add(id, s);
                }
            }
            else
            {
                s = Tools.CopyNode(t.Subject, factory);
            }

            if (t.Predicate.NodeType == NodeType.Blank)
            {
                id = t.Predicate.GetHashCode() + "-" + t.Graph.GetHashCode();
                if (mapping.ContainsKey(id))
                {
                    p = mapping[id];
                }
                else
                {
                    p = factory.CreateBlankNode(id);
                    mapping.Add(id, p);
                }
            }
            else
            {
                p = Tools.CopyNode(t.Predicate, factory);
            }

            if (t.Object.NodeType == NodeType.Blank)
            {
                id = t.Object.GetHashCode() + "-" + t.Graph.GetHashCode();
                if (mapping.ContainsKey(id))
                {
                    o = mapping[id];
                }
                else
                {
                    o = factory.CreateBlankNode(id);
                    mapping.Add(id, o);
                }
            }
            else
            {
                o = Tools.CopyNode(t.Object, factory);
            }

            return new Triple(s, p, o);
        }
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:70,代码来源:BaseDescribeAlgorithm.cs

示例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);
            }
//.........这里部分代码省略.........
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:101,代码来源:VirtuosoManager.cs


注:本文中的INodeFactory.CreateBlankNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。