Add doc
This commit is contained in:
@@ -4,11 +4,32 @@ using System.Text;
|
||||
|
||||
namespace PlantBox.Shared.Communication.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// A class serializable to a <see cref="CommandPacket"/>
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public abstract class CommandSerializable<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// Serialize all the values in a string <see cref="Array"/>,
|
||||
/// should contains everything to deserialize
|
||||
/// </summary>
|
||||
/// <returns>Valid arguments for a <see cref="CommandPacket"/></returns>
|
||||
public abstract string[] Serialize();
|
||||
|
||||
/// <summary>
|
||||
/// Create an instance of the class from a string <see cref="Array"/>
|
||||
/// </summary>
|
||||
/// <param name="arguments">Arguments from the <see cref="CommandSerializable{T}.Serialize"/> method</param>
|
||||
/// <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"/>
|
||||
/// </summary>
|
||||
/// <param name="command">Command type</param>
|
||||
/// <param name="id">A valid id</param>
|
||||
/// <returns></returns>
|
||||
public CommandPacket ToCommandPacket(Command command, ulong id)
|
||||
{
|
||||
return new CommandPacket(command, id, Serialize());
|
||||
|
||||
Reference in New Issue
Block a user