Ejemplo n.º 1
0
        private static Node AddSourceNode(NodeTree tree, IRelationMetadata metadata)
        {
            Node sourceNode = new Node(metadata);

            tree.Nodes.Add(sourceNode);

            return(sourceNode);
        }
Ejemplo n.º 2
0
        public BufferTree Parse(MetadataIdentity source, IRelationHeader header)
        {
            NodeTree   nodeTree = NodeParser.Parse(source, header);
            BufferTree tree     = new BufferTree()
            {
                Notation = new DotNotation(),
                Header   = header,
            };

            this.CreateSource(nodeTree.Source, tree);

            return(tree);
        }
Ejemplo n.º 3
0
        private static Node AddNode(NodeTree tree, IRelationMetadata metadata, int?index = null)
        {
            Node thisNode = tree.FindNode(metadata);

            if (thisNode == null && metadata.Parent == null)
            {
                return(null);
            }
            else if (thisNode == null)
            {
                Node parentNode = tree.FindNode(metadata.Parent) ?? AddNode(tree, metadata.Parent);

                if (parentNode != null)
                {
                    thisNode = new Node(metadata);

                    if (thisNode.Metadata.HasFlag(RelationMetadataFlags.Item))
                    {
                        parentNode.Item = thisNode;
                    }
                    else
                    {
                        parentNode.Properties.Add(thisNode);
                    }

                    tree.Nodes.Add(thisNode);

                    if (thisNode.Metadata.HasFlag(RelationMetadataFlags.Recursive | RelationMetadataFlags.Item))
                    {
                        AddNode(tree, thisNode.Metadata.Recursor);
                    }
                }
                else if (index != null)
                {
                    tree.Unreachable.Add(metadata);
                }
            }

            if (thisNode != null && index != null)
            {
                thisNode.Index.Add(index.Value);
            }

            return(thisNode);
        }
Ejemplo n.º 4
0
        public static NodeTree Parse(MetadataIdentity source, IRelationHeader header)
        {
            NodeTree tree = new NodeTree();

            IRelationMetadata sourceMetadata = GetMetadata(source);

            tree.Source = AddSourceNode(tree, sourceMetadata);

            for (int i = 0; i < header.Degree; i++)
            {
                AddNode(tree, header.Attributes[i], index: i);
            }

            if (tree.Unreachable.Any())
            {
                throw RelationException.Unreachable(source, header, tree.Unreachable);
            }

            return(tree);
        }