mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-26 06:28:35 +01:00
added a basic object serialization handler
This commit is contained in:
parent
9b28ff4113
commit
1d56cbd8eb
1 changed files with 5 additions and 0 deletions
|
@ -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<T>(JsonSerializer serializer) {
|
||||
this.AddHandler((buffer, o) => buffer.WriteObject(o, serializer), buffer => buffer.ReadObject<T>(serializer));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue