Add default Command to CommandSerializable<T>

This commit is contained in:
2019-03-23 22:17:14 +01:00
parent 18b9a97b91
commit aa20f9d466

View File

@@ -10,6 +10,11 @@ namespace PlantBox.Shared.Communication.Commands
/// <typeparam name="T"></typeparam>
public abstract class CommandSerializable<T> where T : new()
{
/// <summary>
/// Default <see cref="Communication.Command"/>
/// </summary>
public abstract Command Command { get; }
/// <summary>
/// Serialize all the values in a string <see cref="Array"/>,
/// should contains everything to deserialize
@@ -24,6 +29,15 @@ namespace PlantBox.Shared.Communication.Commands
/// <returns><see cref="T"/> initilized accordingly</returns>
public abstract T Deserialize(string[] arguments);
/// <summary>
/// Convert a <see cref="CommandSerializable{T}"/> to a <see cref="CommandPacket"/>, using <see cref="Command"/>
/// </summary>
/// <param name="id">A valid id</param>
/// <returns></returns>
public CommandPacket ToCommandPacket(ulong id)
{
return new CommandPacket(Command, id, Serialize());
}
/// <summary>
/// Convert a <see cref="CommandSerializable{T}"/> to a <see cref="CommandPacket"/>
/// </summary>