Example #1
0
            public object Deserialize(SerializerArchive archive)
            {
                var obj = new TestClassWithExternalObjectSerializer();

                if (archive.Version == 1)
                {
                    obj.SByte   = archive.ReadSByte();
                    obj.Byte    = archive.ReadByte();
                    obj.Int16   = archive.ReadInt16();
                    obj.UInt16  = archive.ReadUInt16();
                    obj.Int32   = archive.ReadInt32();
                    obj.UInt32  = archive.ReadUInt32();
                    obj.Int64   = archive.ReadInt64();
                    obj.UInt64  = archive.ReadUInt64();
                    obj.Single  = archive.ReadSingle();
                    obj.Double  = archive.ReadDouble();
                    obj.Decimal = archive.ReadDecimal();
                    obj.Char    = archive.ReadChar();
                }
                else
                {
                    throw new VersionNotSupportedException(archive);
                }

                return(obj);
            }
Example #2
0
        public void SerializeAndDeserialize_ObjectOfClassUsingExternalObjectSerializer()
        {
            Serializer.RegisterExternalObjectSerializer(typeof(TestClassWithGenericObjectSerializer_ExternalObjectSerializer));

            var obj  = new TestClassWithExternalObjectSerializer();
            var copy = SerializeAndDeserializeObject(obj) as TestClassWithExternalObjectSerializer;

            Assert.Equal(obj, copy);
        }
Example #3
0
 protected bool Equals(TestClassWithExternalObjectSerializer other)
 {
     return(SByte == other.SByte &&
            Byte == other.Byte &&
            Int16 == other.Int16 &&
            UInt16 == other.UInt16 &&
            Int32 == other.Int32 &&
            UInt32 == other.UInt32 &&
            Int64 == other.Int64 &&
            UInt64 == other.UInt64 &&
            Single.Equals(other.Single) &&
            Double.Equals(other.Double) &&
            Decimal == other.Decimal &&
            Char == other.Char);
 }
 protected bool Equals(TestClassWithExternalObjectSerializer other)
 {
     return(BooleanFalse == other.BooleanFalse &&
            BooleanTrue == other.BooleanTrue &&
            Char == other.Char &&
            SByte == other.SByte &&
            Byte == other.Byte &&
            Int16 == other.Int16 &&
            UInt16 == other.UInt16 &&
            Int32 == other.Int32 &&
            UInt32 == other.UInt32 &&
            Int64 == other.Int64 &&
            UInt64 == other.UInt64 &&
            Single.Equals(other.Single) &&
            Double.Equals(other.Double) &&
            Decimal == other.Decimal &&
            String == other.String &&
            DateTime == other.DateTime &&
            DateTimeOffset == other.DateTimeOffset &&
            Guid == other.Guid &&
            NonGenericType == other.NonGenericType &&
            GenericTypeDefinition == other.GenericTypeDefinition &&
            ClosedConstructedGenericType == other.ClosedConstructedGenericType &&
            NullReference == other.NullReference &&
            Enum_S8 == other.Enum_S8 &&
            Enum_U8 == other.Enum_U8 &&
            Enum_S16 == other.Enum_S16 &&
            Enum_U16 == other.Enum_U16 &&
            Enum_S32 == other.Enum_S32 &&
            Enum_U32 == other.Enum_U32 &&
            Enum_S64 == other.Enum_S64 &&
            Enum_U64 == other.Enum_U64 &&
            SerializableObject.SequenceEqual(other.SerializableObject) &&
            ByteArrayEqualityComparer.AreEqual(Buffer1, other.Buffer1) &&
            ByteArrayEqualityComparer.AreEqual(Buffer2, other.Buffer2));
 }