public static void CheckIntIsInRange(ParameterInfo parameterInfo, object argument, Attribute attribute)
        {
            var intIsAttribute = (IntIsInRangeAttribute)attribute;
            var value          = NumericOperations.ConvertToInt(argument, parameterInfo);

            switch (intIsAttribute.IncludingBorders)
            {
            case IncludingBorders.None:
                Checks.ExecutePreconditionCheck(() => value > intIsAttribute.Lower && value < intIsAttribute.Upper,
                                                () => $"{parameterInfo.Name} must be in Range ]{intIsAttribute.Lower}..{intIsAttribute.Upper}[ but found {value}");
                break;

            case IncludingBorders.Lower:
                Checks.ExecutePreconditionCheck(() => value >= intIsAttribute.Lower && value < intIsAttribute.Upper,
                                                () => $"{parameterInfo.Name} must be in Range [{intIsAttribute.Lower}..{intIsAttribute.Upper}[ but found {value}");
                break;

            case IncludingBorders.Upper:
                Checks.ExecutePreconditionCheck(() => value > intIsAttribute.Lower && value <= intIsAttribute.Upper,
                                                () => $"{parameterInfo.Name} must be in Range ]{intIsAttribute.Lower}..{intIsAttribute.Upper}] but found {value}");
                break;

            case IncludingBorders.Lower | IncludingBorders.Upper:
                Checks.ExecutePreconditionCheck(() => value >= intIsAttribute.Lower && value <= intIsAttribute.Upper,
                                                () => $"{parameterInfo.Name} must be in Range [{intIsAttribute.Lower}..{intIsAttribute.Upper}] but found {value}");
                break;

            default: throw new PreconditionViolatedException("unknown range border definition");
            }
        }
Ejemplo n.º 2
0
    public T InnerProduct(Vector <T> v2)
    {
        T result = NumericOperations.Multiply(this[MinIndex], v2[v2.MinIndex]);

        for (int i = v2.MinIndex + 1; i <= v2.MaxIndex; i++)
        {
            result = NumericOperations.Multiply(result, NumericOperations.Multiply(this[i], v2[i]));
        }

        return(result);
    }
Ejemplo n.º 3
0
    //operator overloading for '*' operator. multiplying t1 with every index of v1
    public static Vector <T> operator *(Vector <T> v1, T t1)
    {
        Vector <T> result = new Vector <T>(v1.Length, v1.MinIndex);

        /*    if( mulTT == null )
         *  {
         *      mulTT = new BinaryOperatorT<T,T,T>( GenericOperatorFactory<T, T, T, Vector<T>>.Multiply );
         *  }*/

        for (int i = v1.MinIndex; i <= v1.MaxIndex; i++)
        {
            result[i] = NumericOperations.Multiply(v1[i], t1);
        }
        return(result);
    }
Ejemplo n.º 4
0
    //operator overloading for '-' operator. Substracting v1 from t1
    public static Vector <T> operator -(T t1, Vector <T> v1)
    {
        Vector <T> result = new Vector <T>(v1.Length, v1.MinIndex);

        /*    if( subTT == null )
         *  {
         *      subTT = new BinaryOperatorT<T,T,T>( GenericOperatorFactory<T, T, T, Vector<T>>.Subtract );
         *  }*/

        for (int i = v1.MinIndex; i <= v1.MaxIndex; i++)
        {
            result[i] = NumericOperations.Subtract(t1, v1[i]);
        }
        return(result);
    }
Ejemplo n.º 5
0
    //Operator overloading for '+' operator. Adding v2 to v1
    public static Vector <T> operator +(Vector <T> v1, Vector <T> v2)
    {
        Vector <T> result = new Vector <T>(v1.Length, v1.MinIndex);
        int        delta  = v1.MinIndex - v2.MinIndex;

        /*   if( addTT == null )
         * {
         *     addTT = new BinaryOperatorT<T,T,T>( GenericOperatorFactory<T, T, T, Vector<T>>.Add );
         * }*/

        for (int i = v1.MinIndex; i <= v1.MaxIndex; i++)
        {
            result[i] = NumericOperations.Add(v1[i], v2[(i - delta)]);
        }
        return(result);
    }
Ejemplo n.º 6
0
 /// <summary>
 /// Creates a new instance of <see cref="NumericFilterCondition"/>.
 /// </summary>
 /// <param name="property">The property name, case insensitive.</param>
 /// <param name="operation">The operation to compare.</param>
 protected NumericFilterCondition(string property, NumericOperations operation)
 {
     Property = property;
     Operation = operation;
 }
Ejemplo n.º 7
0
 public static NumberValue operator /(NumberValue a, NumberValue b) => NumericOperations.Mul(a, b.Inv());
Ejemplo n.º 8
0
 public static NumberValue operator *(NumberValue a, NumberValue b) => NumericOperations.Mul(a, b);
Ejemplo n.º 9
0
 public static NumberValue operator -(NumberValue a, NumberValue b) => NumericOperations.Add(a, b.Neg());
Ejemplo n.º 10
0
 public static NumberValue operator +(NumberValue a, NumberValue b) => NumericOperations.Add(a, b);
Ejemplo n.º 11
0
 /// <summary>
 /// Creates a new instance of <see cref="DateTimeFilterCondition"/>.
 /// </summary>
 /// <param name="property">The property name, case insensitive.</param>
 /// <param name="filter">The value used to filter.</param>
 /// <param name="filterTo">The other value used to filter. Used when the operation == "inRange"</param>
 /// <param name="operation">The operation to compare.</param>
 public DateTimeFilterCondition(string property, string filter, string filterTo, NumericOperations operation) : base(property, operation)
 {
     ParseFiltersValues(filter, filterTo);
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Creates a new instance of <see cref="DateTimeFilterCondition"/>.
 /// </summary>
 /// <param name="property">The property name, case insensitive.</param>
 /// <param name="filter">The value used to filter.</param>
 /// <param name="filterTo">The other value used to filter. Used when the operation == "inRange"</param>
 /// <param name="operation">The operation to compare.</param>
 public DateTimeFilterCondition(string property, DateTime?filter, DateTime?filterTo, NumericOperations operation) : base(property, operation)
 {
     Filter   = filter;
     FilterTo = filterTo;
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Creates a new instance of <see cref="DoubleFilterCondition"/>.
 /// </summary>
 /// <param name="property">The property name, case insensitive.</param>
 /// <param name="filter">The value used to filter.</param>
 /// <param name="filterTo">The other value used to filter. Used when the operation == "inRange"</param>
 /// <param name="operation">The operation to compare.</param>
 public DoubleFilterCondition(string property, double?filter, double?filterTo, NumericOperations operation) : base(property, operation)
 {
     Filter   = filter;
     FilterTo = filterTo;
 }