mirror of
https://github.com/MilkBarModding/MilkBarLauncher.git
synced 2025-06-16 20:20:56 +00:00
36 lines
700 B
C#
36 lines
700 B
C#
namespace BOTWM.Server.JSONBuilder
|
|
{
|
|
|
|
public class JSONFormat<T>
|
|
{
|
|
|
|
private bool UsesLambda = false;
|
|
public int Size;
|
|
public string Function;
|
|
public Func<T> Lambda;
|
|
|
|
public JSONFormat(int size, string function = "", Func<T> lambda = null)
|
|
{
|
|
this.Size = size;
|
|
|
|
if(function != null)
|
|
Function = function;
|
|
else
|
|
{
|
|
Lambda = lambda;
|
|
UsesLambda = true;
|
|
}
|
|
|
|
}
|
|
|
|
public T ToObject(byte[] data)
|
|
{
|
|
|
|
return (T)typeof(BitConverter).GetMethod(Function).Invoke(null, new[] {data});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|