Пример #1
0
        /// <summary>
        /// Default method for combining two <see cref="IntervalData{TDest}"/> values.
        /// </summary>
        /// <param name="left">The first value to combine.</param>
        /// <param name="right">The second value to combine.</param>
        /// <returns>The combined value.</returns>
        public static IntervalData <TDest> DefaultCombiner(IntervalData <TDest> left, IntervalData <TDest> right)
        {
            Comparer <TDest> comparer = Comparer <TDest> .Default;
            TDest            min      = comparer.Compare(left.Minimum, right.Minimum) < 0 ? left.Minimum : right.Minimum;
            TDest            max      = comparer.Compare(left.Maximum, right.Maximum) > 0 ? left.Maximum : right.Maximum;
            TDest            value;
            DateTime         originatingTime;

            // Take the value which occurs last, and the time which occurs first
            if (left.OriginatingTime <= right.OriginatingTime)
            {
                value           = right.Value;
                originatingTime = left.OriginatingTime;
            }
            else
            {
                value           = left.Value;
                originatingTime = right.OriginatingTime;
            }

            // Take the whichever end time occurs last and use it to find the interval
            TimeSpan interval = (right.EndTime > left.EndTime ? right.EndTime : left.EndTime) - originatingTime;

            return(IntervalData.Create(value, min, max, originatingTime, interval));
        }
Пример #2
0
 /// <inheritdoc />
 public IntervalData <TDest> Combine(IntervalData <TDest> left, IntervalData <TDest> right)
 {
     return(this.combiner(left, right));
 }