Esempio n. 1
0
        public void TestTypes()
        {
            object[] expected = { 2, 3L, 4f, 5.0d, "abc", new byte[] { 10, 20 }, (byte)20, (short)21, true, new MyBean("E1") };
            var      classes  = new Type[expected.Length];

            for (var i = 0; i < expected.Length; i++)
            {
                classes[i] = expected.GetType();
            }

            var serializers = SerializerFactory.GetSerializers(classes);
            var bytes       = SerializerFactory.Serialize(serializers, expected);

            var result = SerializerFactory.Deserialize(expected.Length, bytes, serializers);

            EPAssertionUtil.AssertEqualsExactOrder(expected, result);

            // null values are simply not serialized
            bytes = SerializerFactory.Serialize(new[] { SerializerFactory.GetSerializer(typeof(int?)) }, new object[] { null });
            Assert.AreEqual(0, bytes.Length);
        }
Esempio n. 2
0
 /// <summary>Serialize object to byte array. </summary>
 /// <param name="underlying">to serialize</param>
 /// <returns>byte array</returns>
 public static byte[] ObjectToByteArr(object underlying)
 {
     return(SerializerFactory.Serialize(
                new[] { SerializerFactory.OBJECT_SERIALIZER },
                new[] { underlying }));
 }