Equal overrides

This commit is contained in:
2024-01-29 17:05:13 +01:00
parent 60c1ece41d
commit 90f804c7c6
7 changed files with 79 additions and 1 deletions

View File

@ -29,4 +29,20 @@ public struct OpenShockShocker : IShocker
$"Created On: {createdOn}\n" +
$"Paused: {isPaused}\n\r";
}
public override bool Equals(object? obj)
{
return obj is OpenShockShocker oss && Equals(oss);
}
private bool Equals(OpenShockShocker other)
{
return id == other.id && rfId == other.rfId && model == other.model && createdOn.Equals(other.createdOn);
}
public override int GetHashCode()
{
return HashCode.Combine(id, rfId, (int)model, createdOn);
}
}

View File

@ -5,4 +5,19 @@ namespace CShocker.Shockers;
public struct PiShockShocker : IShocker
{
public string Code;
public override bool Equals(object? obj)
{
return obj is PiShockShocker pss && Equals(pss);
}
private bool Equals(PiShockShocker other)
{
return Code == other.Code;
}
public override int GetHashCode()
{
return Code.GetHashCode();
}
}