Add CaptorsRequest
This commit is contained in:
@@ -7,39 +7,14 @@ namespace PlantBox.Shared.Communication.Commands
|
|||||||
{
|
{
|
||||||
public class CaptorsRequest : CommandSerializable<CaptorsRequest>
|
public class CaptorsRequest : CommandSerializable<CaptorsRequest>
|
||||||
{
|
{
|
||||||
public CaptorsInterval Interval { get; set; }
|
|
||||||
public int Number { get; set; }
|
|
||||||
|
|
||||||
public CaptorsRequest()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
public CaptorsRequest(CaptorsInterval interval, int number)
|
|
||||||
{
|
|
||||||
Interval = interval;
|
|
||||||
Number = number;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override CaptorsRequest Deserialize(string[] arguments)
|
public override CaptorsRequest Deserialize(string[] arguments)
|
||||||
{
|
{
|
||||||
if (arguments == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(arguments));
|
|
||||||
}
|
|
||||||
if (arguments.Length < 2)
|
|
||||||
{
|
|
||||||
throw new ArgumentException($"Excepted 2 arguments, got {arguments.Length}");
|
|
||||||
}
|
|
||||||
|
|
||||||
Interval = (CaptorsInterval)Enum.Parse(typeof(CaptorsInterval), arguments[0], true);
|
|
||||||
Number = int.Parse(arguments[0], CultureInfo.InvariantCulture);
|
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string[] Serialize()
|
public override string[] Serialize()
|
||||||
{
|
{
|
||||||
return new[] { Interval.ToString(), Number.ToString(CultureInfo.InvariantCulture) };
|
return Array.Empty<string>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user