using System; using System.Collections; using System.Collections.Generic; using System.Runtime.CompilerServices; using Unity.UIWidgets.foundation; namespace UIWidgetsSample { public abstract class EquatableMixin: IEquatable { /// {@macro equatable_props} private List props { get; } /// {@macro equatable_stringify} // ignore: avoid_returning_null bool? stringify { get { return null; } } public static bool operator ==(EquatableMixin left,EquatableMixin right) { return Equals(left, right) && Equals(left.props, right.props); } public static bool operator !=(EquatableMixin left, EquatableMixin right) { return !(left == right); } //@override int get hashCode => runtimeType.hashCode ^ mapPropsToHashCode(props); public override string ToString() { switch (stringify) { case true: return EquatableUtils.mapPropsToString(this.GetType(), props); case false: return this.GetType().ToString(); default: return EquatableConfig.stringify == true ? EquatableUtils.mapPropsToString(this.GetType(), props) : this.GetType().ToString(); } } public bool Equals(EquatableMixin other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return Equals(props, other.props); } public override bool Equals(object obj) { if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(this, obj)) return true; if (obj.GetType() != this.GetType()) return false; return Equals((EquatableMixin) obj); } public override int GetHashCode() { return (props != null ? props.GetHashCode() : 0); } } }