public static byte[] Serialize(BObject obj) { var bson = new Bson(); var ms = new MemoryStream(); bson.EncodeDocument(ms, obj); byte[] buf = new byte[ms.Position]; ms.Seek(0, SeekOrigin.Begin); ms.Read(buf, 0, buf.Length); return(buf); }
public static BObject Load(byte[] buf) { var bson = new Bson(buf); return(bson.DecodeDocument()); }