using System;
using LoreSoft.MathExpressions.Properties;
namespace LoreSoft.MathExpressions
{
/// The base class for expressions
public abstract class ExpressionBase : IExpression
{
/// Gets the number of arguments this expression uses.
/// The argument count.
public abstract int ArgumentCount { get; }
private MathEvaluate _evaluateDelegate;
/// Gets or sets the evaluate delegate.
/// The evaluate delegate.
public virtual MathEvaluate Evaluate
{
get { return _evaluateDelegate; }
set { _evaluateDelegate = value; }
}
/// Validates the specified numbers for the expression.
/// The numbers to validate.
/// When numbers is null.
/// When the length of numbers do not equal .
protected void Validate(double[] numbers)
{
if (numbers == null)
throw new ArgumentNullException("numbers");
if (numbers.Length != ArgumentCount)
throw new ArgumentException(Resources.InvalidLengthOfArray, "numbers");
}
}
}