Ejemplo n.º 1
0
 /// <summary>
 /// Initializes new instance of a time interval from the interfaces an upper and a lower interval reference values.
 /// </summary>
 /// <param name="upper">The interface to the upper interval boundary to set the interval with.</param>
 /// <param name="lower">The interface to the lower interval boundary to set the interval with.</param>
 /// <param name="type">The time interval flexibility mode to set to the time interval.</param>
 public TimeInterval(IIntervalUpper <DateTime> upper, IIntervalLower <DateTime> lower, IntervalType type = IntervalType.Flex)
 {
     _limits = IntervalLimits.Lower | IntervalLimits.Upper;
     if (upper != null)
     {
         if (upper.UpperInclude)
         {
             _limits &= ~IntervalLimits.Lower;
         }
         _lower = upper.Upper;
     }
     if (lower != null)
     {
         if (upper == null)
         {
             _lower = lower.Lower;
         }
         if (lower.LowerInclude)
         {
             _limits &= ~IntervalLimits.Upper;
         }
         _upper = lower.Lower;
     }
     _span = _upper - _lower;
     Type  = type;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Compares two interfaces to the lower contiguous interval boundaries.
        /// </summary>
        /// <param name="x">The 1-st lower contiguous interval boundary to compare.</param>
        /// <param name="y">The 2-nd lower contiguous interval boundary to compare.</param>
        /// <returns>A value that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less
        /// than zero This instance precedes other in the sort order. Zero This instance occurs in the same position in the sort order as other.
        /// Greater than zero This instance follows other in the sort order.</returns>
        public static int CompareLower(IIntervalLower <T> x, IIntervalLower <T> y)
        {
            if (!(x is null))
            {
                if (!(y is null))
                {
                    switch (Comparer <T?> .Default.Compare(x.Lower, y.Lower))
                    {
                    case 0: return(Comparer <bool> .Default.Compare(x.LowerInclude, y.LowerInclude));

                    case int result when x.Lower == null: return(-1);

                    case int result when y.Lower == null: return(1);

                    case int result: return(result);
                    }
                }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes the new instance of the stream block fragment based on upper and lower range/span limit values.
 /// </summary>
 /// <param name="upper">The interface to the upper interval boundary to set the interval with.</param>
 /// <param name="lower">The interface to the lower interval boundary to set the interval with.</param>
 public Fragment(IIntervalUpper <DateTime> upper, IIntervalLower <DateTime> lower)
 {
     _interval = new TimeInterval(upper, lower);
 }