public void TestObjectSerialization() { IoBuffer buf = ByteBufferAllocator.Instance.Allocate(16); buf.AutoExpand = true; List <Object> o = new List <Object>(); o.Add(new DateTime()); o.Add(typeof(Int64)); // Test writing an object. buf.PutObject(o); // Test reading an object. buf.Clear(); Object o2 = buf.GetObject(); #if !NETFX_CORE Assert.IsInstanceOf(o.GetType(), o2); #else Assert.IsInstanceOfType(o2, o.GetType()); #endif List <Object> l2 = (List <Object>)o2; Assert.AreEqual(o.Count, l2.Count); for (Int32 i = 0; i < o.Count; i++) { Assert.AreEqual(o[i], l2[i]); } // This assertion is just to make sure that deserialization occurred. Assert.AreNotSame(o, o2); }
/// <inheritdoc/> public override IoBuffer PutObject(Object o) { _buf.PutObject(o); return(this); }