public bool Equals(KeyValuePair <string, object> x, KeyValuePair <string, object> y) { object xValue = ModUtils.GetSettingUnderlyingValue(x.Value); object yValue = ModUtils.GetSettingUnderlyingValue(y.Value); return(x.Key == y.Key && EqualityComparer <object> .Default.Equals(xValue, yValue)); }
public bool Equals(IBindable x, IBindable y) { object xValue = x == null ? null : ModUtils.GetSettingUnderlyingValue(x); object yValue = y == null ? null : ModUtils.GetSettingUnderlyingValue(y); return(EqualityComparer <object> .Default.Equals(xValue, yValue)); }
public override int GetHashCode() { var hashCode = new HashCode(); hashCode.Add(GetType()); foreach (var setting in Settings) { hashCode.Add(ModUtils.GetSettingUnderlyingValue(setting)); } return(hashCode.ToHashCode()); }
public void Serialize(ref MessagePackWriter writer, Dictionary <string, object> value, MessagePackSerializerOptions options) { var primitiveFormatter = PrimitiveObjectFormatter.Instance; writer.WriteArrayHeader(value.Count); foreach (var kvp in value) { var stringBytes = new ReadOnlySequence <byte>(Encoding.UTF8.GetBytes(kvp.Key)); writer.WriteString(in stringBytes); primitiveFormatter.Serialize(ref writer, ModUtils.GetSettingUnderlyingValue(kvp.Value), options); } }
public APIMod(Mod mod) { Acronym = mod.Acronym; foreach (var(_, property) in mod.GetSettingsSourceProperties()) { var bindable = (IBindable)property.GetValue(mod); if (!bindable.IsDefault) { Settings.Add(property.Name.Underscore(), ModUtils.GetSettingUnderlyingValue(bindable)); } } }
public bool Equals(Mod other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(GetType() == other.GetType() && this.GetSettingsSourceProperties().All(pair => EqualityComparer <object> .Default.Equals( ModUtils.GetSettingUnderlyingValue(pair.Item2.GetValue(this)), ModUtils.GetSettingUnderlyingValue(pair.Item2.GetValue(other))))); }
public int GetHashCode(IBindable obj) => ModUtils.GetSettingUnderlyingValue(obj).GetHashCode();
public int GetHashCode(KeyValuePair <string, object> obj) => HashCode.Combine(obj.Key, ModUtils.GetSettingUnderlyingValue(obj.Value));