diff --git a/SFVvCommon/SapiStyle.cs b/SFVvCommon/SapiStyle.cs index 01f0a51..0f5e735 100644 --- a/SFVvCommon/SapiStyle.cs +++ b/SFVvCommon/SapiStyle.cs @@ -50,38 +50,29 @@ public string SpaiName /// public Guid CLSID { get; set; } - #region Equalsの自動実装 - public override bool Equals(object obj) { - var style = obj as SapiStyle; - return style != null && - Name == style.Name && - StyleName == style.StyleName && - ID == style.ID && + return obj is SapiStyle style && + base.Equals(obj) && CLSID.Equals(style.CLSID); } public override int GetHashCode() { - var hashCode = 2064203553; - hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(Name); - hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(StyleName); - hashCode = hashCode * -1521134295 + ID.GetHashCode(); - hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(CLSID); + int hashCode = 2093058940; + hashCode = hashCode * -1521134295 + base.GetHashCode(); + hashCode = hashCode * -1521134295 + CLSID.GetHashCode(); return hashCode; } - public static bool operator ==(SapiStyle style1, SapiStyle style2) + public static bool operator ==(SapiStyle left, SapiStyle right) { - return EqualityComparer.Default.Equals(style1, style2); + return EqualityComparer.Default.Equals(left, right); } - public static bool operator !=(SapiStyle style1, SapiStyle style2) + public static bool operator !=(SapiStyle left, SapiStyle right) { - return !(style1 == style2); + return !(left == right); } - - #endregion } } diff --git a/SFVvCommon/StyleBase.cs b/SFVvCommon/StyleBase.cs index a4cfbc9..9c6fb9b 100644 --- a/SFVvCommon/StyleBase.cs +++ b/SFVvCommon/StyleBase.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; namespace SFVvCommon { @@ -49,5 +50,36 @@ public StyleBase(string appName, string name, string styleName, int iD, int port /// ポート番号 /// public int Port { get; set; } + + public override bool Equals(object obj) + { + return obj is StyleBase style && + AppName == style.AppName && + Name == style.Name && + StyleName == style.StyleName && + ID == style.ID && + Port == style.Port; + } + + public override int GetHashCode() + { + int hashCode = 830617096; + hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(AppName); + hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(Name); + hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(StyleName); + hashCode = hashCode * -1521134295 + ID.GetHashCode(); + hashCode = hashCode * -1521134295 + Port.GetHashCode(); + return hashCode; + } + + public static bool operator ==(StyleBase left, StyleBase right) + { + return EqualityComparer.Default.Equals(left, right); + } + + public static bool operator !=(StyleBase left, StyleBase right) + { + return !(left == right); + } } }