コード例 #1
0
        public IEnumerable <DocumentModel.Row> Generate()
        {
            this.Databind();
            List <DocumentModel.Row> rows = new List <DocumentModel.Row>();

            DataSourceBrowser browser;

            if (!string.IsNullOrWhiteSpace(this.DataMember))
            {
                browser = new ObjectDataSourceBrowser((this.DataSource ?? new ObjectDataSourceBrowser(DataBindingContext.Peek())).GetValue(this.DataMember));
            }
            else
            {
                browser = this.DataSource;
            }

            if (browser != null)
            {
                while (browser.MoveNext())
                {
                    DataBindingContext.Push(browser.Current);

                    if (this.Header != null)
                    {
                        rows.AddRange(this.Header.Generate());
                    }

                    if (this.SubSection != null)
                    {
                        rows.AddRange(this.SubSection.Generate());
                    }

                    if (this.Footer != null)
                    {
                        rows.AddRange(this.Footer.Generate());
                    }
                }

                DataBindingContext.Pop();
            }
            else
            {
                if (this.Header != null)
                {
                    rows.AddRange(this.Header.Generate());
                }

                if (this.SubSection != null)
                {
                    rows.AddRange(this.SubSection.Generate());
                }

                if (this.Footer != null)
                {
                    rows.AddRange(this.Footer.Generate());
                }
            }

            return(rows);
        }
コード例 #2
0
        protected internal override void PerformBind(ReportControl obj)
        {
            if (obj == null)
            {
                throw new ArgumentNullException(nameof(obj));
            }

            var source = this.DataSource;

            if (source == null)
            {
                var newSource = DataBindingContext.Peek();
                source = newSource as DataSourceBrowser;
                if (source == null)
                {
                    source = new ObjectDataSourceBrowser(newSource);
                }
            }

            object value      = source.GetValue(this.Expression);
            var    objectType = obj.GetType();
            var    setter     = GetWriter(objectType);

            setter(obj, this.PropertyName, value);
        }
コード例 #3
0
        protected internal override void PerformBind(ReportControl reportControl)
        {
            var source = this.DataSource;

            if (source == null)
            {
                var newSource = DataBindingContext.Peek();
                source = newSource as DataSourceBrowser;
                if (source == null)
                {
                    source = new ObjectDataSourceBrowser(newSource);
                }
            }

            this.ExpressionEvaluator.Evaluate(new EvaluationContext
            {
                Target     = reportControl,
                Expression = this.Expression,
                Source     = source.Current
            });
        }
コード例 #4
0
        public Document Generate()
        {
            List <DocumentModel.Sheet> sheets = new List <DocumentModel.Sheet>();

            if (this.DataSource != null)
            {
                DataSourceBrowser browser;
                if (!string.IsNullOrWhiteSpace(this.DataMember))
                {
                    browser = new ObjectDataSourceBrowser(this.DataSource, this.DataMember);
                    while (browser.MoveNext())
                    {
                        DataBindingContext.Push(browser.Current);
                        sheets.AddRange(this.Sheets.Select(s => s.Generate()));
                        DataBindingContext.Pop();
                    }
                }
                else
                {
                    while (this.DataSource.MoveNext())
                    {
                        DataBindingContext.Push(this.DataSource.Current);
                        sheets.AddRange(this.Sheets.Select(s => s.Generate()));
                        DataBindingContext.Pop();
                    }
                }
            }
            else
            {
                sheets.AddRange(this.Sheets.Select(s => s.Generate()));
            }

            Document doc = new Document(sheets);

            return(doc);
        }