Skip to content

Commit

Permalink
Merge pull request #109 from shigobu/スタイル比較処理更新
Browse files Browse the repository at this point in the history
スタイル比較処理の再生成
  • Loading branch information
shigobu authored Dec 4, 2024
2 parents 125e2d4 + 3b48f7b commit c35da21
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 18 deletions.
27 changes: 9 additions & 18 deletions SFVvCommon/SapiStyle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,38 +50,29 @@ public string SpaiName
/// </summary>
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<string>.Default.GetHashCode(Name);
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(StyleName);
hashCode = hashCode * -1521134295 + ID.GetHashCode();
hashCode = hashCode * -1521134295 + EqualityComparer<Guid>.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<SapiStyle>.Default.Equals(style1, style2);
return EqualityComparer<SapiStyle>.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
}
}
32 changes: 32 additions & 0 deletions SFVvCommon/StyleBase.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;

namespace SFVvCommon
{
Expand Down Expand Up @@ -49,5 +50,36 @@ public StyleBase(string appName, string name, string styleName, int iD, int port
/// ポート番号
/// </summary>
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<string>.Default.GetHashCode(AppName);
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(Name);
hashCode = hashCode * -1521134295 + EqualityComparer<string>.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<StyleBase>.Default.Equals(left, right);
}

public static bool operator !=(StyleBase left, StyleBase right)
{
return !(left == right);
}
}
}

0 comments on commit c35da21

Please sign in to comment.