Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Interval&lt;T&gt;"/> class.
 /// </summary>
 /// <param name="lowerDirection">The lower direction.</param>
 /// <param name="lowerValue">The lower value.</param>
 /// <param name="upperValue">The upper value.</param>
 /// <param name="upperDirection">The upper direction.</param>
 public Interval(BoundDirection lowerDirection
                 , T lowerValue
                 , T upperValue
                 , BoundDirection upperDirection)
     : this(new Bound <T>(BoundType.Lower, lowerDirection, lowerValue)
            , new Bound <T>(BoundType.Upper, upperDirection, upperValue))
 {
 }
Esempio n. 2
0
        internal Bound(BoundType type, BoundDirection direction, T value, bool checkArguments)
        {
            if (checkArguments && Bound.IsInfinity(value) && direction == BoundDirection.Closed)
            {
                throw new ArgumentException("An infinity bound must define an opened direction.");
            }

            Type      = type;
            Direction = direction;
            Value     = value;
        }
Esempio n. 3
0
        internal static bool TryParse <T>(BoundType type
                                          , BoundDirection direction
                                          , T value
                                          , out Bound <T> result)
        {
            result = (Bound.IsInfinity(value) && direction == BoundDirection.Closed)
                ? default(Bound <T>)
                : new Bound <T>(type, direction, value);

            return(result != default(Bound <T>));
        }
Esempio n. 4
0
        internal static bool TryParse <T>(BoundDirection lowerDirection
                                          , T lowerValue
                                          , T upperValue
                                          , BoundDirection upperDirection
                                          , out Interval <T> result)
        {
            Bound <T> lowerBound, upperBound;

            if (Bound.TryParse(BoundType.Lower, lowerDirection, lowerValue, out lowerBound) &&
                Bound.TryParse(BoundType.Upper, upperDirection, upperValue, out upperBound))
            {
                return(Interval.TryParse(lowerBound, upperBound, out result));
            }

            result = default(Interval <T>);
            return(false);
        }
Esempio n. 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Bound&lt;T&gt;"/> class.
 /// </summary>
 /// <param name="type">The bound type.</param>
 /// <param name="direction">The bound direction.</param>
 /// <param name="value">The bound value.</param>
 /// <exception cref="ArgumentException">An infinity bound must define an <see cref="P:Direction.Opened"/> direction.</exception>
 public Bound(BoundType type, BoundDirection direction, T value)
     : this(type, direction, value, true)
 {
 }
Esempio n. 6
0
 internal static BoundDirection Reverse(BoundDirection value)
 {
     return(value == BoundDirection.Closed ? BoundDirection.Opened : BoundDirection.Closed);
 }
Esempio n. 7
0
 internal static BoundDirection Max(BoundDirection x, BoundDirection y)
 {
     return(x < y ? y : x);
 }
Esempio n. 8
0
 internal static BoundDirection Min(BoundDirection x, BoundDirection y)
 {
     return(x > y ? y : x);
 }