Add CommandSerializable
Used to easily serialize class to CommandPacket
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using PlantBox.Shared.Communication.Commands;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|||||||
@@ -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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user