using System; using System.Collections.Generic; namespace Xamarin.PropertyEditing { public class ValueInfo : IEquatable> { public T Value { get; set; } /// /// Gets or sets a descriptor of the value, such as a string value name or . /// /// /// public object ValueDescriptor { get; set; } public ValueSource Source { get; set; } /// /// Gets or sets a descriptor for the source, such as a or binding. /// /// /// public object SourceDescriptor { get; set; } public string CustomExpression { get; set; } public bool Equals (ValueInfo other) { if (ReferenceEquals (null, other)) return false; if (ReferenceEquals (this, other)) return true; return EqualityComparer.Default.Equals (Value, other.Value) && Equals (ValueDescriptor, other.ValueDescriptor) && Source == other.Source && Equals (SourceDescriptor, other.SourceDescriptor) && CustomExpression == other.CustomExpression; } public override bool Equals (object obj) { if (ReferenceEquals (null, obj)) return false; if (ReferenceEquals (this, obj)) return true; if (obj.GetType () != GetType ()) return false; return Equals ((ValueInfo) obj); } public override int GetHashCode () { unchecked { var hashCode = EqualityComparer.Default.GetHashCode (Value); hashCode = (hashCode * 397) ^ (ValueDescriptor?.GetHashCode () ?? 0); hashCode = (hashCode * 397) ^ (int) Source; hashCode = (hashCode * 397) ^ (SourceDescriptor?.GetHashCode () ?? 0); hashCode = (hashCode * 397) ^ (CustomExpression?.GetHashCode () ?? 0); return hashCode; } } public static bool operator == (ValueInfo left, ValueInfo right) { return Equals (left, right); } public static bool operator != (ValueInfo left, ValueInfo right) { return !Equals (left, right); } } }