Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

スタイル比較処理の再生成 #109

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}
}
Loading