TimeInterval<T>
Represents a value associated with time interval information.
The time interval can represent the time it took to produce the value, the interval relative to a previous value, the value's delivery time relative to a base, etc.
using System.Collections.Generic;
using System.Globalization;
using System.Runtime.CompilerServices;
namespace System.Reactive
{
[Serializable]
[System.Runtime.CompilerServices.NullableContext(1)]
[System.Runtime.CompilerServices.Nullable(0)]
public readonly struct TimeInterval<[System.Runtime.CompilerServices.Nullable(2)] T> : IEquatable<TimeInterval<T>>
{
public T Value { get; }
public TimeSpan Interval { get; }
public TimeInterval(T value, TimeSpan interval)
{
Interval = interval;
Value = value;
}
public void Deconstruct(out T value, out TimeSpan interval)
{
T value2 = Value;
TimeSpan interval2 = Interval;
value = value2;
interval = interval2;
}
public bool Equals([System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1
})] TimeInterval<T> other)
{
if (other.Interval.Equals(Interval))
return EqualityComparer<T>.Default.Equals(Value, other.Value);
return false;
}
public static bool operator ==([System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1
})] TimeInterval<T> first, [System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1
})] TimeInterval<T> second)
{
return first.Equals(second);
}
public static bool operator !=([System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1
})] TimeInterval<T> first, [System.Runtime.CompilerServices.Nullable(new byte[] {
0,
1
})] TimeInterval<T> second)
{
return !first.Equals(second);
}
[System.Runtime.CompilerServices.NullableContext(2)]
public override bool Equals(object obj)
{
if (obj is TimeInterval<T>) {
TimeInterval<T> other = (TimeInterval<T>)obj;
return Equals(other);
}
return false;
}
public override int GetHashCode()
{
int hashCode = Interval.GetHashCode();
T value = Value;
return hashCode ^ (value?.GetHashCode() ?? 1963);
}
public override string ToString()
{
return string.Format(CultureInfo.CurrentCulture, "{0}@{1}", Value, Interval);
}
}
}