53 lines
1.3 KiB
C#
53 lines
1.3 KiB
C#
using PlantBox.Shared.Extensions;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using System.Text;
|
|
|
|
namespace PlantBox.Shared.Communication.Commands
|
|
{
|
|
public class HistoricRequest : CommandSerializable<HistoricRequest>
|
|
{
|
|
public override Command Command => Command.Historic;
|
|
|
|
public HistoricInterval Interval { get; set; }
|
|
public int Number { get; set; }
|
|
|
|
public HistoricRequest()
|
|
{
|
|
|
|
}
|
|
public HistoricRequest(HistoricInterval interval, int number)
|
|
{
|
|
Interval = interval;
|
|
Number = number;
|
|
}
|
|
|
|
public override HistoricRequest 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 = arguments[0].ToEnumValue<HistoricInterval>();
|
|
Number = arguments[1].ToInt();
|
|
|
|
return this;
|
|
}
|
|
|
|
public override string[] Serialize()
|
|
{
|
|
return new[]
|
|
{
|
|
Interval.ToString(),
|
|
Number.ToArgument()
|
|
};
|
|
}
|
|
}
|
|
}
|