CShock/CShocker/Shockers/OpenShockShocker.cs

62 lines
1.8 KiB
C#
Raw Permalink Normal View History

2024-02-12 02:01:31 +01:00
using CShocker.Devices.Abstract;
using CShocker.Shockers.Abstract;
namespace CShocker.Shockers;
public class OpenShockShocker : Shocker
{
2024-02-12 02:01:31 +01:00
// ReSharper disable thrice MemberCanBePrivate.Global -> Exposed
public readonly string Name, ID;
public readonly short RfId;
public readonly OpenShockModel Model;
public readonly DateTime CreatedOn;
public readonly bool IsPaused;
public OpenShockShocker(Api api, string name, string id, short rfId, OpenShockModel model, DateTime createdOn, bool isPaused) : base (api)
{
if (api is not OpenShockApi)
throw new Exception($"API-Type {api.GetType().FullName} is not usable with Shocker {this.GetType().FullName}");
this.Name = name;
this.ID = id;
this.RfId = rfId;
this.Model = model;
this.CreatedOn = createdOn;
this.IsPaused = isPaused;
}
public enum OpenShockModel : byte
{
CaiXianlin = 0,
Petrainer = 1
}
public override string ToString()
{
2024-02-12 03:06:28 +01:00
const int tabWidth = -12;
return $"\t{string.Join("\n\t",
$"\u251c {"Type",tabWidth}: {GetType().Name}",
$"\u251c {"Name",tabWidth}: {Name}",
$"\u251c {"ID",tabWidth}: {ID}",
$"\u251c {"RF-ID",tabWidth}: {RfId}",
$"\u251c {"Model",tabWidth}: {Enum.GetName(Model)}",
$"\u251c {"Created On",tabWidth}: {CreatedOn}",
$"\u2514 {"Paused",tabWidth}: {IsPaused}")}" +
$"\n\r";
}
2024-01-29 17:05:13 +01:00
public override bool Equals(object? obj)
{
return obj is OpenShockShocker oss && Equals(oss);
}
private bool Equals(OpenShockShocker other)
{
return ID == other.ID;
2024-01-29 17:05:13 +01:00
}
public override int GetHashCode()
{
return ID.GetHashCode();
2024-01-29 17:05:13 +01:00
}
}