コード例 #1
0
 public void Serialize(ref JsonWriter ptr, TargetClassContractless targetClassContractless, IJsonFormatterResolver jsonFormatterResolver)
 {
     if (targetClassContractless == null)
     {
         ptr.WriteNull();
         return;
     }
     UnsafeMemory64.WriteRaw11(ref ptr, this.stringByteKeys[0]);
     ptr.WriteSByte(targetClassContractless.Number1);
     UnsafeMemory64.WriteRaw11(ref ptr, this.stringByteKeys[1]);
     ptr.WriteInt16(targetClassContractless.Number2);
     UnsafeMemory64.WriteRaw11(ref ptr, this.stringByteKeys[2]);
     ptr.WriteInt32(targetClassContractless.Number3);
     UnsafeMemory64.WriteRaw11(ref ptr, this.stringByteKeys[3]);
     ptr.WriteInt64(targetClassContractless.Number4);
     UnsafeMemory64.WriteRaw11(ref ptr, this.stringByteKeys[4]);
     ptr.WriteByte(targetClassContractless.Number5);
     UnsafeMemory64.WriteRaw11(ref ptr, this.stringByteKeys[5]);
     ptr.WriteUInt16(targetClassContractless.Number6);
     UnsafeMemory64.WriteRaw11(ref ptr, this.stringByteKeys[6]);
     ptr.WriteUInt32(targetClassContractless.Number7);
     UnsafeMemory64.WriteRaw11(ref ptr, this.stringByteKeys[7]);
     ptr.WriteUInt64(targetClassContractless.Number8);
     UnsafeMemory64.WriteRaw7(ref ptr, this.stringByteKeys[8]);
     ptr.WriteString(targetClassContractless.Str);
     UnsafeMemory64.WriteRaw9(ref ptr, this.stringByteKeys[9]);
     JsonFormatterResolverExtensions.GetFormatterWithVerify <int[]>(jsonFormatterResolver).Serialize(ref ptr, targetClassContractless.Array, jsonFormatterResolver);
     ptr.WriteEndObject();
 }
コード例 #2
0
        public unsafe TargetClassContractless Deserialize(ref JsonReader ptr, IJsonFormatterResolver jsonFormatterResolver)
        {
            if (ptr.ReadIsNull())
            {
                return(null);
            }
            ptr.ReadIsBeginObjectWithVerify();
            byte[] bufferUnsafe = ptr.GetBufferUnsafe();
            string str          = default;

            int[]  array   = default;
            sbyte  number  = default;
            short  number2 = default;
            int    number3 = default;
            long   number4 = default;
            byte   number5 = default;
            ushort number6 = default;
            uint   number7 = default;
            ulong  number8 = default;

            fixed(byte *ptr2 = &bufferUnsafe[0])
            {
                int num = default;

                while (!ptr.ReadIsEndObjectWithSkipValueSeparator(ref num))
                {
                    ArraySegment <byte> arraySegment = ptr.ReadPropertyNameSegmentRaw();
                    byte *ptr3  = ptr2 + arraySegment.Offset;
                    int   count = arraySegment.Count;
                    if (count != 0)
                    {
                        ulong key = AutomataKeyGen.GetKey(ref ptr3, ref count);
                        if (key < 14762478557558094uL)
                        {
                            if (key < 13918053627426126uL)
                            {
                                if (count == 0)
                                {
                                    if (key == 7500883uL)
                                    {
                                        str = ptr.ReadString();
                                        continue;
                                    }
                                    if (key == 521325933121uL)
                                    {
                                        array = JsonFormatterResolverExtensions.GetFormatterWithVerify <int[]>(jsonFormatterResolver).Deserialize(ref ptr, jsonFormatterResolver);
                                        continue;
                                    }
                                }
                            }
                            else
                            {
                                if (count == 0)
                                {
                                    if (key == 13918053627426126uL)
                                    {
                                        number = ptr.ReadSByte();
                                        continue;
                                    }
                                    if (key == 14199528604136782uL)
                                    {
                                        number2 = ptr.ReadInt16();
                                        continue;
                                    }
                                    if (key == 14481003580847438uL)
                                    {
                                        number3 = ptr.ReadInt32();
                                        continue;
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (key < 15325428510979406uL)
                            {
                                if (count == 0)
                                {
                                    if (key == 14762478557558094uL)
                                    {
                                        number4 = ptr.ReadInt64();
                                        continue;
                                    }
                                    if (key == 15043953534268750uL)
                                    {
                                        number5 = ptr.ReadByte();
                                        continue;
                                    }
                                }
                            }
                            else
                            {
                                if (count == 0)
                                {
                                    if (key == 15325428510979406uL)
                                    {
                                        number6 = ptr.ReadUInt16();
                                        continue;
                                    }
                                    if (key == 15606903487690062uL)
                                    {
                                        number7 = ptr.ReadUInt32();
                                        continue;
                                    }
                                    if (key == 15888378464400718uL)
                                    {
                                        number8 = ptr.ReadUInt64();
                                        continue;
                                    }
                                }
                            }
                        }
                    }
                    ptr.ReadNextBlock();
                }
            }

            return(new TargetClassContractless
            {
                Number1 = number,
                Number2 = number2,
                Number3 = number3,
                Number4 = number4,
                Number5 = number5,
                Number6 = number6,
                Number7 = number7,
                Number8 = number8,
                Str = str,
                Array = array
            });
        }