Equal overrides
This commit is contained in:
@ -69,6 +69,21 @@ public abstract class Device : IDisposable
|
||||
$"DurationRange: {DurationRange}\n\r";
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
return obj is Device d && Equals(d);
|
||||
}
|
||||
|
||||
protected bool Equals(Device other)
|
||||
{
|
||||
return IntensityRange.Equals(other.IntensityRange) && DurationRange.Equals(other.DurationRange) && ApiType == other.ApiType;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(IntensityRange, DurationRange, (int)ApiType);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_workQueue = false;
|
||||
|
@ -18,7 +18,22 @@ public abstract class OpenShockDevice : Device
|
||||
this.Endpoint = endpoint;
|
||||
this.ApiKey = apiKey;
|
||||
}
|
||||
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
return obj is OpenShockDevice osd && Equals(osd);
|
||||
}
|
||||
|
||||
private bool Equals(OpenShockDevice other)
|
||||
{
|
||||
return base.Equals(other) && Endpoint == other.Endpoint && ApiKey == other.ApiKey;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(Endpoint, ApiKey);
|
||||
}
|
||||
|
||||
public List<OpenShockShocker> GetShockers()
|
||||
{
|
||||
List<OpenShockShocker> shockers = new();
|
||||
|
Reference in New Issue
Block a user