Add default Command to CommandSerializable<T>
This commit is contained in:
@@ -10,6 +10,11 @@ namespace PlantBox.Shared.Communication.Commands
|
|||||||
/// <typeparam name="T"></typeparam>
|
/// <typeparam name="T"></typeparam>
|
||||||
public abstract class CommandSerializable<T> where T : new()
|
public abstract class CommandSerializable<T> where T : new()
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Default <see cref="Communication.Command"/>
|
||||||
|
/// </summary>
|
||||||
|
public abstract Command Command { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Serialize all the values in a string <see cref="Array"/>,
|
/// Serialize all the values in a string <see cref="Array"/>,
|
||||||
/// should contains everything to deserialize
|
/// should contains everything to deserialize
|
||||||
@@ -24,6 +29,15 @@ namespace PlantBox.Shared.Communication.Commands
|
|||||||
/// <returns><see cref="T"/> initilized accordingly</returns>
|
/// <returns><see cref="T"/> initilized accordingly</returns>
|
||||||
public abstract T Deserialize(string[] arguments);
|
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>
|
/// <summary>
|
||||||
/// Convert a <see cref="CommandSerializable{T}"/> to a <see cref="CommandPacket"/>
|
/// Convert a <see cref="CommandSerializable{T}"/> to a <see cref="CommandPacket"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user