using System; namespace Ingvar.LiveWatch { [Serializable] public struct WatchValue : IEquatable> where T : IEquatable { public T Value; public bool IsEmpty; public string ValueText { get; set; } public WatchValue(T value) { Value = value; IsEmpty = false; ValueText = null; } public static WatchValue Empty() { return new WatchValue() { IsEmpty = true, }; } public bool Equals(WatchValue other) { return this == other; } public static bool operator ==(WatchValue left, WatchValue right) { if (!left.IsEmpty && !right.IsEmpty) return left.Value.Equals(right.Value); return left.IsEmpty == right.IsEmpty; } public static bool operator !=(WatchValue left, WatchValue right) { return !(left == right); } public override bool Equals(object obj) { return base.Equals(obj); } public override int GetHashCode() { return base.GetHashCode(); } } }