예제 #1
0
        /// <summary>Deserialize byte arry to object. </summary>
        /// <param name="bytes">to read</param>
        /// <returns>object</returns>
        public static Object ByteArrToObject(byte[] bytes)
        {
            if (bytes == null)
            {
                return(null);
            }

            return(SerializerFactory.Deserialize(
                       1, bytes, new[] { SerializerFactory.OBJECT_SERIALIZER })[0]);
        }
예제 #2
0
        public void TestTypes()
        {
            Object[] expected = new Object[] { 2, 3L, 4f, 5.0d, "abc", new byte[] { 10, 20 }, (byte)20, (short)21, true, new MyBean("E1") };
            Type[]   classes  = new Type[expected.Length];
            for (int i = 0; i < expected.Length; i++)
            {
                classes[i] = expected.GetType();
            }

            Serializer[] serializers = SerializerFactory.GetSerializers(classes);
            byte[]       bytes       = SerializerFactory.Serialize(serializers, expected);

            Object[] result = SerializerFactory.Deserialize(expected.Length, bytes, serializers);
            EPAssertionUtil.AssertEqualsExactOrder(expected, result);

            // null values are simply not serialized
            bytes = SerializerFactory.Serialize(new Serializer[] { SerializerFactory.GetSerializer(typeof(int)) }, new Object[] { null });
            Assert.AreEqual(0, bytes.Length);
        }