1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-22 20:58:34 +01:00

added a basic object serialization handler

This commit is contained in:
Ellpeck 2019-12-20 22:02:17 +01:00
parent 9b28ff4113
commit 1d56cbd8eb

View file

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using Lidgren.Network; using Lidgren.Network;
using Newtonsoft.Json;
namespace MLEM.Data { namespace MLEM.Data {
public class NetBufferSerializer { public class NetBufferSerializer {
@ -57,5 +58,9 @@ namespace MLEM.Data {
this.readFunctions.Add(typeof(T), buffer => read(buffer)); this.readFunctions.Add(typeof(T), buffer => read(buffer));
} }
public void AddHandler<T>(JsonSerializer serializer) {
this.AddHandler((buffer, o) => buffer.WriteObject(o, serializer), buffer => buffer.ReadObject<T>(serializer));
}
} }
} }