mirror of
https://github.com/MoleskiCoder/EightBitNet.git
synced 2025-08-05 06:26:35 +00:00
35 lines
970 B
C#
35 lines
970 B
C#
namespace SM83.HarteTest
|
|
{
|
|
internal sealed class Cycle
|
|
{
|
|
public ushort Address { get; set; }
|
|
|
|
public byte? Value { get; set; }
|
|
|
|
public string Type { get; set; }
|
|
|
|
public Cycle(ushort address, byte? value, string type)
|
|
{
|
|
this.Address = address;
|
|
this.Value = value;
|
|
this.Type = type;
|
|
}
|
|
|
|
public Cycle(List<object> input)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(input);
|
|
|
|
if (input.Count != 3)
|
|
{
|
|
throw new ArgumentOutOfRangeException(nameof(input), input, "Cycles can only have three elements");
|
|
}
|
|
|
|
this.Address = AsElement(input[0]).GetUInt16();
|
|
this.Value = AsElement(input[1]).GetByte();
|
|
this.Type = AsElement(input[2]).GetString();
|
|
}
|
|
|
|
private static System.Text.Json.JsonElement AsElement(object part) => (System.Text.Json.JsonElement)part;
|
|
}
|
|
}
|