From 8d70879c6829568a02a7f704bab272fc8b42cc0b Mon Sep 17 00:00:00 2001 From: glax Date: Mon, 12 Feb 2024 02:03:35 +0100 Subject: [PATCH] Capitalized FieldNames onn public fields --- CShocker/Devices/APIs/OpenShockHttp.cs | 2 +- CShocker/Devices/APIs/OpenShockSerial.cs | 4 +-- CShocker/Shockers/OpenShockShocker.cs | 37 +++++++++++------------- 3 files changed, 20 insertions(+), 23 deletions(-) diff --git a/CShocker/Devices/APIs/OpenShockHttp.cs b/CShocker/Devices/APIs/OpenShockHttp.cs index 0337e43..4b71e6e 100644 --- a/CShocker/Devices/APIs/OpenShockHttp.cs +++ b/CShocker/Devices/APIs/OpenShockHttp.cs @@ -19,7 +19,7 @@ public class OpenShockHttp : OpenShockApi string json = "{" + " \"shocks\": [" + " {" + - $" \"id\": \"{openShockShocker.id}\"," + + $" \"id\": \"{openShockShocker.ID}\"," + $" \"type\": {ControlActionToByte(action)}," + $" \"intensity\": {intensity}," + $" \"duration\": {duration}" + diff --git a/CShocker/Devices/APIs/OpenShockSerial.cs b/CShocker/Devices/APIs/OpenShockSerial.cs index 1ef8662..5b8ba00 100644 --- a/CShocker/Devices/APIs/OpenShockSerial.cs +++ b/CShocker/Devices/APIs/OpenShockSerial.cs @@ -36,8 +36,8 @@ public class OpenShockSerial : OpenShockApi return; } string json = "rftransmit {" + - $"\"model\":\"{Enum.GetName(openShockShocker.model)!.ToLower()}\"," + - $"\"id\":{openShockShocker.rfId}," + + $"\"model\":\"{Enum.GetName(openShockShocker.Model)!.ToLower()}\"," + + $"\"id\":{openShockShocker.RfId}," + $"\"type\":\"{ControlActionToString(action)}\"," + $"\"intensity\":{intensity}," + $"\"durationMs\":{duration}" + diff --git a/CShocker/Shockers/OpenShockShocker.cs b/CShocker/Shockers/OpenShockShocker.cs index 4fc831c..504eb98 100644 --- a/CShocker/Shockers/OpenShockShocker.cs +++ b/CShocker/Shockers/OpenShockShocker.cs @@ -11,22 +11,17 @@ public class OpenShockShocker : Shocker public readonly OpenShockModel Model; public readonly DateTime CreatedOn; public readonly bool IsPaused; - public string name, id; - public short rfId; - public OpenShockModel model; - public DateTime createdOn; - public 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; + this.Name = name; + this.ID = id; + this.RfId = rfId; + this.Model = model; + this.CreatedOn = createdOn; + this.IsPaused = isPaused; } public enum OpenShockModel : byte @@ -37,13 +32,15 @@ public class OpenShockShocker : Shocker public override string ToString() { - return $"{GetType().Name}\n" + - $"Name: {name}\n" + - $"ID: {id}\n" + - $"RF-ID: {rfId}\n" + - $"Model: {Enum.GetName(model)}\n" + - $"Created On: {createdOn}\n" + - $"Paused: {isPaused}\n\r"; + return $"{string.Join("\n\t", + $"{GetType().Name}", + $"Name: {Name}", + $"ID: {ID}", + $"RF-ID: {RfId}", + $"Model: {Enum.GetName(Model)}", + $"Created On: {CreatedOn}", + $"Paused: {IsPaused}")}" + + $"\n\r"; } public override bool Equals(object? obj) @@ -54,11 +51,11 @@ public class OpenShockShocker : Shocker private bool Equals(OpenShockShocker other) { - return id == other.id && rfId == other.rfId && model == other.model && createdOn.Equals(other.createdOn); + return ID == other.ID; } public override int GetHashCode() { - return HashCode.Combine(id, rfId, (int)model, createdOn); + return ID.GetHashCode(); } } \ No newline at end of file