Timestamped<T>
using System.Collections.Generic;
using System.Globalization;
namespace System.Reactive
{
[Serializable]
public struct Timestamped<T> : IEquatable<Timestamped<T>>
{
public T Value { get; }
public DateTimeOffset Timestamp { get; }
public Timestamped(T value, DateTimeOffset timestamp)
{
Timestamp = timestamp;
Value = value;
}
public bool Equals(Timestamped<T> other)
{
if (other.Timestamp.Equals(Timestamp))
return EqualityComparer<T>.Default.Equals(Value, other.Value);
return false;
}
public static bool operator ==(Timestamped<T> first, Timestamped<T> second)
{
return first.Equals(second);
}
public static bool operator !=(Timestamped<T> first, Timestamped<T> second)
{
return !first.Equals(second);
}
public override bool Equals(object obj)
{
if (!(obj is Timestamped<T>))
return false;
Timestamped<T> other = (Timestamped<T>)obj;
return Equals(other);
}
public override int GetHashCode()
{
int hashCode = Timestamp.GetHashCode();
T value = Value;
ref T reference = ref value;
T val = default(T);
int num;
if (val == null) {
val = reference;
ref reference = ref val;
if (val == null) {
num = 1979;
goto IL_0050;
}
}
num = reference.GetHashCode();
goto IL_0050;
IL_0050:
return hashCode ^ num;
}
public override string ToString()
{
return string.Format(CultureInfo.CurrentCulture, "{0}@{1}", Value, Timestamp);
}
}
}