Add CommandSerializable

Used to easily serialize class to CommandPacket
This commit is contained in:
2019-03-22 19:57:33 +01:00
parent 58fbaf4e35
commit faa54aca0e
2 changed files with 19 additions and 1 deletions

View File

@@ -1,4 +1,5 @@
using System;
using PlantBox.Shared.Communication.Commands;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace PlantBox.Shared.Communication.Commands
{
public abstract class CommandSerializable<T>
{
public abstract string[] Serialize();
public abstract T Deserialize(string[] arguments);
public CommandPacket ToCommandPacket(Command command, ulong id)
{
return new CommandPacket(command, id, Serialize());
}
}
}