Пример #1
0
        public AggregateResult Parse(IEnumerable <AggregateAttribute> header)
        {
            NodeTree nodeTree = NodeParser.Parse(this.Schema, header);

            Node valueNode = nodeTree.Items.FirstOrDefault(this.IsResultNode);
            Node itemNode  = nodeTree.Items.FirstOrDefault(this.IsResultListNode);

            AggregateResult result = new AggregateResult(this.Schema);

            if (itemNode != null)
            {
                result.Value  = this.CreateReader(result, itemNode);
                result.Target = new AggregateTarget()
                {
                    AddMethod = itemNode.Metadata.Parent.Composition.Add,
                    NewList   = itemNode.Metadata.Parent.Composition.Construct,
                };
            }
            else
            {
                result.Value = this.CreateReader(result, valueNode);
            }

            return(result);
        }
Пример #2
0
        private void AddAggregates(ListResult result, NodeTree nodeTree)
        {
            foreach (Node node in nodeTree.Nodes.Where(n => n.Data != null && this.IsAggregateValue(n.Metadata)))
            {
                int bufferIndex = this.Buffer.GetAggregateIndex(node.Identity);

                AggregateWriter writer = new AggregateWriter(node)
                {
                    Attribute = new AggregateAttribute(node.Identity.Name, aggregateIndex: bufferIndex, listIndex: null),
                    Value     = this.CreateDataReader(result, node)
                };

                result.Aggregates.Add(writer);
            }

            foreach (Node node in nodeTree.Items.Where(n => this.IsAggregateList(n.Metadata)))
            {
                int bufferIndex = this.Buffer.GetListIndex(node.Metadata);

                AggregateWriter writer = new AggregateWriter(node)
                {
                    Attribute = new AggregateAttribute(node.Metadata.Parent.Identity.Name, aggregateIndex: null, listIndex: bufferIndex),
                };

                result.Aggregates.Add(writer);
            }
        }
Пример #3
0
        public ListResult Parse(IEnumerable <ColumnAttribute> header)
        {
            NodeTree   nodeTree = NodeParser.Parse(this.Schema, header);
            ListResult result   = new ListResult(this.Schema, this.QueryType);

            this.AddWriters(result, nodeTree);
            this.AddAggregates(result, nodeTree);

            return(result);
        }
Пример #4
0
        public static NodeTree Parse(ISchema schema, IEnumerable <DataAttribute> header)
        {
            NodeTree tree = new NodeTree(schema);

            foreach (DataAttribute attribute in header)
            {
                AddDataNode(tree, attribute);
            }

            return(tree);
        }
Пример #5
0
        public EnumerateResult Parse(IEnumerable <ColumnAttribute> header)
        {
            NodeTree nodeTree = NodeParser.Parse(this.Schema, header);

            Node valueNode = nodeTree.Items.FirstOrDefault(this.IsResultNode);
            Node listNode  = nodeTree.Items.FirstOrDefault(this.IsResultListNode);

            EnumerateResult result = new EnumerateResult(this.Schema);

            result.Value = this.CreateReader(result, listNode ?? valueNode);

            return(result);
        }
Пример #6
0
        private void AddWriters(ListResult result, NodeTree nodeTree)
        {
            foreach (Node node in nodeTree.Items.Where(n => this.IsWriterList(n.Metadata)).OrderByDescending(n => n.Depth))
            {
                TargetWriter writer = new TargetWriter()
                {
                    Source = this.CreateReader(result, node),
                };

                this.AddPrimaryKey(writer);
                this.AddChildKey(result, writer);

                result.Writers.Add(writer);
            }

            TargetWriter resultWriter     = result.Writers.FirstOrDefault(w => w.Source.Metadata.Relation.Depth == 0);
            TargetWriter resultItemWriter = result.Writers.FirstOrDefault(w => w.Source.Metadata.Relation.Depth == 1);

            if (resultWriter != null && resultItemWriter != null)
            {
                result.Writers.Remove(resultWriter);
            }
        }