예제 #1
0
        private static unsafe void deSerialize(AutoCSer.BinarySerialize.DeSerializer deSerializer, ref CustomClass value)
        {
            byte *read = deSerializer.CustomRead;

            if (deSerializer.VerifyRead(sizeof(int)))
            {
                switch (*(int *)read)
                {
                case 1: value = new CustomClass {
                        Value = null
                }; return;

                case 2: value = new CustomClass {
                        Value = string.Empty
                }; return;

                default: deSerializer.MoveRead(-1); return;
                }
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            Console.WriteLine(@"http://www.AutoCSer.com/Serialize/Binary.html
");

            Console.WriteLine(Reference.TestCase());
            Console.WriteLine(DisabledReference.TestCase());
            Console.WriteLine(PublicInstanceField.TestCase());
            Console.WriteLine(AnonymousType.TestCase());
            Console.WriteLine(MemberMap.TestCase());
            Console.WriteLine(DisabledMemberMap.TestCase());
            Console.WriteLine(MemberMapValue.TestCase());
            Console.WriteLine(Property.TestCase());
            Console.WriteLine(IgnoreMember.TestCase());
            Console.WriteLine(CustomClass.TestCase());
            Console.WriteLine(CustomStruct.TestCase());
            Console.WriteLine(GlobalVersion.TestCase());
            Console.WriteLine(Json.TestCase());
            Console.WriteLine(BaseType.TestCase());
            Console.WriteLine(RealType.TestCase());
            Console.WriteLine("Over");
            Console.ReadKey();
        }
예제 #3
0
 internal static void Serialize(AutoCSer.BinarySerialize.Serializer serializer, CustomClass value)
 {
     serializer.Stream.Write(value.Value == null ? 1 : 2);
 }