Exemplo n.º 1
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);
        }
        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
            });
        }
Exemplo n.º 3
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);
        }