private static void DeserializeFormat0(ref MessagePackReader reader, MessagePackSerializerOptions options, ref string message, ref int number)
    {
        int length = reader.ReadMapHeader();
        int i      = 0;
        IFormatterResolver resolver = options.Resolver;

        while (i < length)
        {
            ReadOnlySpan <byte> stringKey = CodeGenHelpers.ReadStringSpan(ref reader);
            int   length2 = stringKey.Length;
            ulong key     = 0uL;
            if (length2 <= 8)
            {
                key = AutomataKeyGen.GetKey(ref stringKey);
            }

            if (length2 == 7 && key == 28542640894207341L)
            {
                message = reader.ReadString();
            }
            else if (length2 == 6 && key == 125779768604014L)
            {
                number = reader.ReadInt32();
            }
            else
            {
                reader.Skip();
            }

            i++;
        }
    }
Пример #2
0
        public static ulong GetKeyName(string name)
        {
            byte[] binary            = utf8.GetBytes(name);
            ReadOnlySpan <byte> span = binary;
            int keyLength            = binary.Length >> 3;

            keyLength += keyLength << 3 == binary.Length ? 0 : 1;
            ulong[] k = new ulong[keyLength];
            for (int j = 0; j < k.Length; j++)
            {
                k[j] = AutomataKeyGen.GetKey(ref span);
            }

            return(k[0]);
        }
Пример #3
0
        public unsafe void KeyGen(string str)
        {
            var bytes = Encoding.UTF8.GetBytes(str);
            var rest  = bytes.Length;

            fixed(byte *buf = bytes)
            {
                var p  = buf;
                var l1 = AutomataKeyGen.GetKey(ref p, ref rest);

                var offset = 0;

                rest = bytes.Length;
                var l2 = AutomataKeyGen.GetKeySafe(bytes, ref offset, ref rest);

                l1.Is(l2);
            }
        }
        private static void DeserializeFormat0(ref MessagePackReader reader, MessagePackSerializerOptions options, ref Type type, ref IExposedWrapper wrapper)
        {
            int count    = reader.ReadMapHeader();
            int typeHash = 0;

            for (int i = 0; i < count; i++)
            {
                ReadOnlySpan <byte> stringKey = CodeGenHelpers.ReadStringSpan(ref reader);

                switch (stringKey.Length)
                {
                default:
FAIL:
                    reader.Skip();
                    continue;

                case 4:
                    if (AutomataKeyGen.GetKey(ref stringKey) != 1701869940UL)
                    {
                        goto FAIL;
                    }

                    typeHash = reader.ReadInt32();
                    type     = LevelEditorSerializer.GetType(typeHash);
                    continue;

                case 10:
                    if (!stringKey.SequenceEqual(SpanProperties.Slice(1)))
                    {
                        goto FAIL;
                    }

                    if (type == null)
                    {
                        Debug.LogWarning($"Couldn't find a wrapper for type hash {typeHash}.");
                        reader.Skip();
                        continue;
                    }

                    ((LevelEditorResolver)LevelEditorResolver.instance).DeserializeWrapper(type, ref reader, options, out wrapper);
                    continue;
                }
            }
        }
Пример #5
0
        private static void DeserializeFormat0(ref MessagePackReader reader, MessagePackSerializerOptions options, ref Type type, ref object value)
        {
            int count    = reader.ReadMapHeader();
            int typeHash = 0;

            for (int i = 0; i < count; i++)
            {
                ReadOnlySpan <byte> stringKey = CodeGenHelpers.ReadStringSpan(ref reader);
                switch (stringKey.Length)
                {
                default:
FAIL:
                    reader.Skip();
                    continue;

                case 4:
                    if (AutomataKeyGen.GetKey(ref stringKey) != 1701869940UL)
                    {
                        goto FAIL;
                    }

                    typeHash = reader.ReadInt32();
                    type     = LevelEditorSerializer.GetType(typeHash);
                    continue;

                case 5:
                    if (AutomataKeyGen.GetKey(ref stringKey) != 435761734006UL)
                    {
                        goto FAIL;
                    }

                    if (type == null)
                    {
                        Debug.LogWarning($"Can't deserialize some custom data because there's no type with hash {typeHash}.");
                        reader.Skip();
                        break;
                    }

                    ((LevelEditorResolver)LevelEditorResolver.instance).DeserializeDynamic(type, ref reader, out value, options);
                    continue;
                }
            }
        }
Пример #6
0
        public unsafe Dup Deserialize(byte[] bytes, int offset, IFormatterResolver formatterResolver, out int readSize)
        {
            if (MessagePackBinary.IsNil(bytes, offset))
            {
                readSize = 1;
                return(null);
            }

            var startOffset = offset;

            var len = MessagePackBinary.ReadMapHeader(bytes, offset, out readSize);

            offset += readSize;


            int aBCDEFGH     = 0;
            int aBCDEFGHIJKL = 0;
            int aBCDEFGHIJKO = 0;

            // ---isStringKey

            ulong key;
            ArraySegment <byte> arraySegment;
            byte *p;
            int   rest;

            fixed(byte *buffer = &bytes[0])
            {
                for (int i = 0; i < len; i++)
                {
                    arraySegment = MessagePackBinary.ReadStringSegment(bytes, offset, out readSize);
                    offset      += readSize;

                    p    = buffer + arraySegment.Offset;
                    rest = arraySegment.Count;

                    if (rest == 0)
                    {
                        goto LOOP_END;
                    }

                    key = AutomataKeyGen.GetKey(ref p, ref rest);
                    if (rest == 0)
                    {
                        if (key == 5208208757389214273L)
                        {
                            aBCDEFGH = MessagePackBinary.ReadInt32(bytes, offset, out readSize);
                            goto LOOP_END;
                        }

                        goto READ_NEXT;
                    }

                    if (key == 5208208757389214273L)
                    {
                        key = AutomataKeyGen.GetKey(ref p, ref rest);
                        if (rest == 0)
                        {
                            if (key == 1280002633L)
                            {
                                aBCDEFGHIJKL = MessagePackBinary.ReadInt32(bytes, offset, out readSize);
                                goto LOOP_END;
                            }

                            if (key == 1330334281L)
                            {
                                aBCDEFGHIJKO = MessagePackBinary.ReadInt32(bytes, offset, out readSize);
                                goto LOOP_END;
                            }
                        }
                    }

READ_NEXT:
                    readSize = MessagePackBinary.ReadNextBlock(bytes, offset);

LOOP_END:
                    offset += readSize;
                    continue;
                }
            }

            // --- end

            return(new Dup
            {
                ABCDEFGH = aBCDEFGH,
                ABCDEFGHIJKL = aBCDEFGHIJKL,
                ABCDEFGHIJKO = aBCDEFGHIJKO
            });
        }
Пример #7
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
            });
        }
Пример #8
0
 public unsafe void KeyGen(string str)
 {
     ReadOnlySpan <byte> bytes = Encoding.UTF8.GetBytes(str);
     var l1 = AutomataKeyGen.GetKey(ref bytes);
 }