Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public static BObject Load(byte[] buf)
        {
            var bson = new Bson(buf);

            return(bson.DecodeDocument());
        }