ToString fancy
This commit is contained in:
@ -32,14 +32,15 @@ public class OpenShockShocker : Shocker
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{string.Join("\n\t",
|
||||
$"{GetType().Name}",
|
||||
$"Name: {Name}",
|
||||
$"ID: {ID}",
|
||||
$"RF-ID: {RfId}",
|
||||
$"Model: {Enum.GetName(Model)}",
|
||||
$"Created On: {CreatedOn}",
|
||||
$"Paused: {IsPaused}")}" +
|
||||
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";
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,13 @@ public class PiShockShocker : Shocker
|
||||
{
|
||||
public readonly string Code;
|
||||
|
||||
public PiShockShocker(Api api, string code) : base(api)
|
||||
{
|
||||
if (api is not PiShockApi)
|
||||
throw new Exception($"API-Type {api.GetType().FullName} is not usable with Shocker {this.GetType().FullName}");
|
||||
Code = code;
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
return obj is PiShockShocker pss && Equals(pss);
|
||||
@ -21,11 +28,13 @@ public class PiShockShocker : Shocker
|
||||
{
|
||||
return Code.GetHashCode();
|
||||
}
|
||||
|
||||
public PiShockShocker(Api api, string code) : base(api)
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
if (api is not PiShockApi)
|
||||
throw new Exception($"API-Type {api.GetType().FullName} is not usable with Shocker {this.GetType().FullName}");
|
||||
Code = code;
|
||||
const int tabWidth = -5;
|
||||
return $"{string.Join("\n\t",
|
||||
$"\u251c {"Type",tabWidth}: {GetType().Name}",
|
||||
$"\u2514 {"Code",tabWidth}: {Code}")}" +
|
||||
$"\n\r";
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user