RangeHelper
Provides helper methods for manipulating Range objects.
Methods
public static IEnumerable<IRange<DateTimeOffset>> Exclude(IRange<DateTimeOffset> from, Range<DateTimeOffset> excludingRange)
result = RangeHelper.Exclude(from, excludingRange)
Excludes the specified DateTimeOffset range from the current range.
- from
- The original DateTimeOffset range.
- excludingRange
- The DateTimeOffset range to exclude.
Returns: A collection of remaining DateTimeOffset ranges after exclusion.
public static IEnumerable<Range<DateTime>> Exclude(Range<DateTime> from, Range<DateTime> excludingRange)
result = RangeHelper.Exclude(from, excludingRange)
Excludes the specified DateTime range from the current range.
- from
- The original DateTime range.
- excludingRange
- The DateTime range to exclude.
Returns: A collection of remaining DateTime ranges after exclusion.
public static IEnumerable<IRange<long>> Exclude(IRange<long> from, IRange<long> excludingRange)
result = RangeHelper.Exclude(from, excludingRange)
Excludes the specified long range from the current long range.
- from
- The original long range.
- excludingRange
- The long range to exclude.
Returns: A collection of remaining long ranges after exclusion.
public static IEnumerable<IRange<DateTimeOffset>> GetRanges(IEnumerable<DateTimeOffset> dates, DateTimeOffset from, DateTimeOffset to)
result = RangeHelper.GetRanges(dates, from, to)
Generates ranges from a sequence of DateTimeOffset values within the specified boundaries.
- dates
- The sequence of DateTimeOffset values.
- from
- The start boundary.
- to
- The end boundary.
Returns: A collection of DateTimeOffset ranges.
public static IEnumerable<Range<DateTime>> GetRanges(IEnumerable<DateTime> dates, DateTime from, DateTime to)
result = RangeHelper.GetRanges(dates, from, to)
Generates ranges from a sequence of DateTime values within the specified boundaries.
- dates
- The sequence of DateTime values.
- from
- The start boundary.
- to
- The end boundary.
Returns: A collection of DateTime ranges.
public static IEnumerable<Range<long>> GetRanges(IEnumerable<long> dates, long from, long to)
result = RangeHelper.GetRanges(dates, from, to)
Generates ranges based on a sequence of long values (ticks) given the specified start and end boundaries.
- dates
- The sequence of long values representing tick counts.
- from
- The starting tick value.
- to
- The ending tick value.
Returns: A collection of ranges represented by long values.
public static bool IsEmpty(IRange range)
result = RangeHelper.IsEmpty(range)
Determines whether the specified range is empty, meaning it has no defined minimum or maximum value.
- range
- The range to check.
Returns: true if the range has no minimum and maximum value; otherwise, false.
public static IEnumerable<IRange<T>> JoinRanges<T>(IEnumerable<IRange<T>> ranges)
result = RangeHelper.JoinRanges(ranges)
Joins overlapping or contiguous ranges in the collection.
- ranges
- The collection of ranges to join.
Returns: A collection of combined ranges.
public static Range<T> ToRange<T>(SettingsStorage storage)
result = RangeHelper.ToRange(storage)
Constructs a Range<T> object from the provided SettingsStorage.
- storage
- The SettingsStorage containing the range data.
Returns: A new Range<T> initialized with the storage values.
public static SettingsStorage ToStorage<T>(IRange<T> range)
result = RangeHelper.ToStorage(range)
Converts the range to a SettingsStorage object for serialization.
- range
- The range to convert.
Returns: A SettingsStorage object containing the range data.