예제 #1
0
        /// <summary>
        /// Returns the result of the operator applied to the operands.
        /// </summary>
        /// <param name="left">The left operand.</param>
        /// <param name="right">The right operand..</param>
        /// <param name="context">
        /// The <see cref="T:Dt.CalcEngine.CalcEvaluatorContext" /> associate with the operator evaluation.
        /// </param>
        /// <returns>
        /// Result of the operator applied to the operand.
        /// </returns>
        public override object Evaluate(object left, object right, CalcEvaluatorContext context)
        {
            CalcReference reference  = left as CalcReference;
            CalcReference reference2 = right as CalcReference;

            if (((reference == null) || (reference2 == null)) || (((reference.RangeCount != 1) || (reference2.RangeCount != 1)) || !reference.GetSource().Equals(reference2.GetSource())))
            {
                return(CalcErrors.Value);
            }
            CalcReference source = reference.GetSource();

            if ((source == null) || !source.Equals(reference2.GetSource()))
            {
                return(CalcErrors.Value);
            }
            int row         = reference.GetRow(0);
            int column      = reference.GetColumn(0);
            int num3        = reference2.GetRow(0);
            int num4        = reference2.GetColumn(0);
            int num5        = Math.Max(row, num3);
            int num6        = Math.Max(column, num4);
            int rowCount    = Math.Min((int)(row + reference.GetRowCount(0)), (int)(num3 + reference2.GetRowCount(0))) - num5;
            int columnCount = Math.Min((int)(column + reference.GetColumnCount(0)), (int)(num4 + reference2.GetColumnCount(0))) - num6;

            if ((rowCount >= 1) && (columnCount >= 1))
            {
                return(new ConcreteReference(source, num5, num6, rowCount, columnCount));
            }
            return(CalcErrors.Null);
        }