Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Dt.CalcEngine.Expressions.CalcErrorExpression" /> class.
 /// </summary>
 /// <param name="value">The error value.</param>
 /// <exception cref="T:System.ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
 public CalcErrorExpression(CalcError value) : base(value)
 {
     if (value == null)
     {
         throw new ArgumentNullException();
     }
 }
Пример #2
0
        /// <summary>
        /// Returns a number corresponding to one of the error values
        /// or returns the #N/A error if no error exists.
        /// </summary>
        /// <param name="args"><para>
        /// The args contains 1 item: error_val.
        /// </para>
        /// <para>
        /// Error_val is the error value whose identifying number you want
        /// to find. Although error_val can be the actual error value,
        /// it will usually be a reference to a cell containing a formula
        /// that you want to test.
        /// </para></param>
        /// <returns>
        /// A <see cref="T:System.Int32" /> value that indicates the evaluate result.
        /// </returns>
        public override object Evaluate(object[] args)
        {
            base.CheckArgumentsLength(args);
            CalcError error = args[0] as CalcError;

            if (error != null)
            {
                switch (error.ErrorCode)
                {
                case 0:
                    return((int)1);

                case 7:
                    return((int)2);

                case 15:
                    return((int)3);

                case 0x17:
                    return((int)4);

                case 0x1d:
                    return((int)5);

                case 0x24:
                    return((int)6);

                case 0x2a:
                    return((int)7);
                }
            }
            return(CalcErrors.NotAvailable);
        }
Пример #3
0
        public static void BadAssert(string input, CalcError output, [CallerLineNumber] int line = 0)
        {
            CalcResult result = new Calc().Solve(input);

            if (result.Error != output)
            {
                Debug.WriteLine("Line " + line + ": " + input + " = " + output.ToString() + ", GOT " + result.Error.ToString());
            }
        }
Пример #4
0
        private bool IsErr(object obj)
        {
            if ((obj is CalcError) && (((CalcError)obj) != CalcErrors.NotAvailable))
            {
                return(true);
            }
            if (!(obj is string))
            {
                return(false);
            }
            CalcError error = CalcErrors.Parse((string)(obj as string), CultureInfo.InvariantCulture);

            return((error != null) && (error != CalcErrors.NotAvailable));
        }
Пример #5
0
		public CalcResult (CalcError error, string errorObject) {
			this.result = double.NaN;
			this.error = error;
			this.errorObject = errorObject;
		}
Пример #6
0
		public CalcResult (CalcError error) {
			this.result = double.NaN;
			this.error = error;
			this.errorObject = "";
		}
Пример #7
0
		public CalcResult (double result) {
			this.result = result;
			this.error = CalcError.None;
			this.errorObject = "";
		}
Пример #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Dt.CalcEngine.Expressions.CalcExternalErrorExpression" /> class.
 /// </summary>
 /// <param name="source">The owner of error.</param>
 /// <param name="value">The error value.</param>
 /// <exception cref="T:System.ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
 public CalcExternalErrorExpression(ICalcSource source, CalcError value) : base(value)
 {
     this._source = source;
 }
Пример #9
0
 public ParseResult(CalcError error, string errorObject)
 {
     this.output      = "";
     this.error       = error;
     this.errorObject = errorObject;
 }
Пример #10
0
		public ParseResult (CalcError error, string errorObject) {
			this.output = "";
			this.error = error;
			this.errorObject = errorObject;
		}
Пример #11
0
 public CalcResult(CalcError error, string errorObject)
 {
     this.result      = double.NaN;
     this.error       = error;
     this.errorObject = errorObject;
 }
Пример #12
0
 public CalcResult(CalcError error)
 {
     this.result      = double.NaN;
     this.error       = error;
     this.errorObject = "";
 }
Пример #13
0
 public CalcResult(double result)
 {
     this.result      = result;
     this.error       = CalcError.None;
     this.errorObject = "";
 }
Пример #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Dt.CalcEngine.Expressions.CalcBangErrorExpression" /> class.
 /// </summary>
 /// <param name="value">The error value.</param>
 /// <exception cref="T:System.ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
 public CalcBangErrorExpression(CalcError value) : base(value)
 {
 }
Пример #15
0
		public static void BadAssert (string input, CalcError output, string errorObject, [CallerLineNumber] int line = 0) {
			CalcResult result = new Calc ().Solve (input);

			if (result.Error != output) {
				Debug.WriteLine ("Line " + line + ": " + input + " = " + output.ToString () + ", GOT " + result.Error.ToString ());
			} else if (result.ErrorObject != errorObject) {
				Debug.WriteLine ("Line " + line + ": " + input + " = " + output.ToString () + " and " + errorObject + ", GOT " + result.Error.ToString () + " and " + result.ErrorObject);
			}
		}
Пример #16
0
		public ParseResult (string result) {
			this.output = result;
			this.error = CalcError.None;
			this.errorObject = "";
		}
Пример #17
0
		public ParseResult (CalcError error) {
			this.output = "";
			this.error = error;
			this.errorObject = "";
		}
Пример #18
0
 public ParseResult(string result)
 {
     this.output      = result;
     this.error       = CalcError.None;
     this.errorObject = "";
 }
Пример #19
0
 public ParseResult(CalcError error)
 {
     this.output      = "";
     this.error       = error;
     this.errorObject = "";
 }
Пример #20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Dt.CalcEngine.Expressions.CalcSheetRangeErrorExpression" /> class.
 /// </summary>
 /// <param name="startSource">Starting owner of error.</param>
 /// <param name="endSource">Ending owner of error.</param>
 /// <param name="value">The error value.</param>
 /// <exception cref="T:System.ArgumentNullException"><paramref name="value" /> is <see langword="null" />.</exception>
 public CalcSheetRangeErrorExpression(ICalcSource startSource, ICalcSource endSource, CalcError value) : base(value)
 {
     this._startSource = startSource;
     this._endSource   = endSource;
 }