/// <summary> /// Initializes a new instance of the <see cref="OperatorDescriptor"/> class. /// </summary> /// <param name="operatorEvaluateMethod">Specifies the operator evaluation method.</param> /// <param name="name">The name of the operator (appears in Toolbox window).</param> /// <param name="stringRepresentation">Specifies how the operator looks in an expression (e.g. "+" for Add operator).</param> /// <param name="precedence">Specifies the operator precedence (e.g. "+" operation should be performed after "*", etc.)</param> /// <param name="primitiveOperator">Specifies whether the operator is primitive (like "add", "substract", "multiply", or "divide").</param> /// <exception cref="ArgumentNullException"> /// <para><paramref name="operatorEvaluateMethod"/> is <see langword="null"/>.</para> /// -or- /// <para><paramref name="name"/> is <see langword="null"/>.</para> /// -or- /// <para><paramref name="name"/> is an empty string.</para> /// -or- /// <para><paramref name="stringRepresentation"/> is <see langword="null"/>.</para> /// -or- /// <para><paramref name="stringRepresentation"/> is an empty string.</para> /// </exception> public OperatorDescriptor( MethodInfo operatorEvaluateMethod , String name , String stringRepresentation , Int32 precedence , PrimitiveOperator primitiveOperator ) { if (operatorEvaluateMethod == null) { throw new ArgumentNullException("operatorEvaluateMethod"); } if (String.IsNullOrEmpty(name)) { throw new ArgumentNullException("name"); } if (String.IsNullOrEmpty(stringRepresentation)) { throw new ArgumentNullException("stringRepresentation"); } _operatorEvaluateMethod = operatorEvaluateMethod; _name = name; _stringRepresentation = stringRepresentation; ParameterInfo[] operatorEvaluateMethodParams = operatorEvaluateMethod.GetParameters(); _inputParameterCount = operatorEvaluateMethodParams.Length; _outputParameterCount = 1; _precedence = precedence; _primitiveOperator = primitiveOperator; }
/// <summary> /// Initializes a new instance of the <see cref="OperatorAttribute"/> class. /// </summary> /// <exception cref="ArgumentNullException"> /// <para><paramref name="name"/> is <see langword="null"/>.</para> /// -or- /// <para><paramref name="name"/> is an empty String.</para> /// -or- /// <para><paramref name="stringRepresentation"/> is <see langword="null"/>.</para> /// -or- /// <para><paramref name="stringRepresentation"/> is an empty String.</para> /// </exception> public OperatorAttribute(String name, String stringRepresentation, Int32 precedence, PrimitiveOperator primitiveOperator) { if (String.IsNullOrEmpty(name)) { throw new ArgumentNullException("name"); } if (String.IsNullOrEmpty(stringRepresentation)) { throw new ArgumentNullException("stringRepresentation"); } _name = name; _stringRepresentation = stringRepresentation; _precedence = precedence; _primitiveOperator = primitiveOperator; }