Пример #1
0
        private object EvaluateConstant(CalcConstantExpression expr, CalcEvaluatorContext context, bool acceptsArray)
        {
            object obj2 = expr.Value;

            if ((obj2 is CalcArray) && (!acceptsArray && ((context == null) || (!context.ArrayFormulaMode && !context.ExpandArrayToMultiCall))))
            {
                return(CalcHelper.GetArrayValue(obj2 as CalcArray, 0, 0));
            }
            return(obj2);
        }
Пример #2
0
        public virtual CalcExpression Visit(CalcExpression expr, int baseRow, int baseColumn)
        {
            CalcConstantExpression expression = expr as CalcConstantExpression;

            if (expression != null)
            {
                return(this.VisitConstantExpression(expression));
            }
            CalcCellExpression expression2 = expr as CalcCellExpression;

            if (expression2 != null)
            {
                return(this.VisitCellExpression(expression2, baseRow, baseColumn));
            }
            CalcRangeExpression expression3 = expr as CalcRangeExpression;

            if (expression3 != null)
            {
                return(this.VisitRangeExpression(expression3, baseRow, baseColumn));
            }
            CalcUnaryOperatorExpression expression4 = expr as CalcUnaryOperatorExpression;

            if (expression4 != null)
            {
                return(this.VisitUnaryOperatorExpression(expression4, baseRow, baseColumn));
            }
            CalcBinaryOperatorExpression expression5 = expr as CalcBinaryOperatorExpression;

            if (expression5 != null)
            {
                return(this.VisitBinaryOperatorExpression(expression5, baseRow, baseColumn));
            }
            CalcFunctionExpression expression6 = expr as CalcFunctionExpression;

            if (expression6 != null)
            {
                return(this.VisitFunctionExpression(expression6, baseRow, baseColumn));
            }
            CalcExternalCellExpression expression7 = expr as CalcExternalCellExpression;

            if (expression7 != null)
            {
                return(this.VisitExternalCellExpression(expression7, baseRow, baseColumn));
            }
            CalcExternalRangeExpression expression8 = expr as CalcExternalRangeExpression;

            if (expression8 != null)
            {
                return(this.VisitExternalRangeExpression(expression8, baseRow, baseColumn));
            }
            if (expr is CalcSharedExpression)
            {
                CalcExpression expression9  = (expr as CalcSharedExpression).Expression;
                CalcExpression expression10 = this.Visit(expression9, baseRow, baseColumn);
                if (expression10 == expression9)
                {
                    return(expr);
                }
                return(new CalcSharedExpression(expression10));
            }
            CalcParenthesesExpression expression11 = expr as CalcParenthesesExpression;

            if (expression11 != null)
            {
                return(this.VisitParenthesesExpression(expression11, baseRow, baseColumn));
            }
            CalcNameExpression expression12 = expr as CalcNameExpression;

            if (expression12 != null)
            {
                return(this.VisitNameExpression(expression12, baseRow, baseColumn));
            }
            CalcExternalNameExpression expression13 = expr as CalcExternalNameExpression;

            if (expression13 != null)
            {
                return(this.VisitExternalNameExpression(expression13, baseRow, baseColumn));
            }
            CalcSheetRangeExpression expression14 = expr as CalcSheetRangeExpression;

            if (expression14 != null)
            {
                return(this.VisitSheetRangeExpression(expression14, baseRow, baseColumn));
            }
            return(expr);
        }
Пример #3
0
        internal virtual void UpdateCollection()
        {
            List <T> list = new List <T>();

            if ((this._dataProviders != null) && (this._dataProviders.Count > 0))
            {
                bool flag = true;
                foreach (ISeriesDataProvider provider in this._dataProviders)
                {
                    int valuesCount = provider.ValuesCount;
                    int seriesCount = provider.SeriesCount;
                    for (int i = 0; i < valuesCount; i++)
                    {
                        object obj2  = null;
                        string str   = null;
                        bool   flag2 = true;
                        for (int j = 0; j < seriesCount; j++)
                        {
                            flag2 = this.DataSeries.DisplayHiddenData || provider.IsValueVisible(j, i);
                            if (flag2)
                            {
                                object obj3 = provider.GetValue(j, i);
                                string text = provider.GetText(j, i);
                                if (j == 0)
                                {
                                    obj2 = obj3;
                                    str  = text;
                                }
                                else
                                {
                                    string str3 = (obj2 != null) ? obj2.ToString() : "";
                                    string str4 = (obj3 != null) ? obj3.ToString() : "";
                                    if (!string.IsNullOrEmpty(str4))
                                    {
                                        obj2 = str3 + this.ValuesSeperator + str4;
                                    }
                                    else
                                    {
                                        obj2 = str3;
                                    }
                                    flag = false;
                                }
                            }
                        }
                        if (flag2)
                        {
                            if (!(obj2 is DateTime))
                            {
                                if (FormatConverter.IsNumber(obj2))
                                {
                                    DateTime time;
                                    if (!string.IsNullOrEmpty(str) && !DateTime.TryParse(str, (IFormatProvider)CultureInfo.CurrentCulture, (DateTimeStyles)DateTimeStyles.None, out time))
                                    {
                                        flag = false;
                                    }
                                }
                                else
                                {
                                    flag = false;
                                }
                            }
                            T local = this.ConvertValue(i, obj2);
                            list.Add(local);
                        }
                    }
                }
                base.items.Clear();
                base.items.AddRange((IEnumerable <T>)list);
                if ((flag != this.IsDateTimeSeries) && (base.items.Count > 0))
                {
                    this.IsDateTimeSeries = flag;
                }
            }
            else if ((this.DataSeries != null) && (this.DataSeries.DataReference is CalcArrayExpression))
            {
                bool flag3 = true;
                CalcArrayExpression dataReference = this.DataSeries.DataReference as CalcArrayExpression;
                if (dataReference.ArrayValue != null)
                {
                    int length = dataReference.ArrayValue.Length;
                    for (int k = 0; k < length; k++)
                    {
                        T local2 = this.ConvertValue(k, dataReference.ArrayValue.GetValue(k));
                        if (flag3 && !(local2 is DateTime))
                        {
                            flag3 = false;
                        }
                        list.Add(local2);
                    }
                }
                base.items.Clear();
                base.items.AddRange((IEnumerable <T>)list);
                if ((flag3 != this.IsDateTimeSeries) && (base.items.Count > 0))
                {
                    this.IsDateTimeSeries = flag3;
                }
            }
            else if ((this.DataSeries != null) && (this.DataSeries.DataReference is CalcConstantExpression))
            {
                CalcConstantExpression expression2 = this.DataSeries.DataReference as CalcConstantExpression;
                T local3 = this.ConvertValue(0, expression2.Value);
                base.items.Clear();
                base.items.Add(local3);
                bool flag4 = local3 is DateTime;
                if (flag4 != this.IsDateTimeSeries)
                {
                    this.IsDateTimeSeries = flag4;
                }
            }
            else
            {
                base.items.Clear();
                this.IsDateTimeSeries = false;
            }
        }
Пример #4
0
 protected virtual CalcExpression VisitConstantExpression(CalcConstantExpression expr)
 {
     return(expr);
 }