From 1d56cbd8ebef89162b7e24af1313628b59a54a80 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Fri, 20 Dec 2019 22:02:17 +0100 Subject: [PATCH] added a basic object serialization handler --- MLEM.Data/NetBufferSerializer.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MLEM.Data/NetBufferSerializer.cs b/MLEM.Data/NetBufferSerializer.cs index 0f41bab..90a7d42 100644 --- a/MLEM.Data/NetBufferSerializer.cs +++ b/MLEM.Data/NetBufferSerializer.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Reflection; using Lidgren.Network; +using Newtonsoft.Json; namespace MLEM.Data { public class NetBufferSerializer { @@ -57,5 +58,9 @@ namespace MLEM.Data { this.readFunctions.Add(typeof(T), buffer => read(buffer)); } + public void AddHandler(JsonSerializer serializer) { + this.AddHandler((buffer, o) => buffer.WriteObject(o, serializer), buffer => buffer.ReadObject(serializer)); + } + } } \ No newline at end of file