Exemple #1
0
        public static Bounds DeserializeStatic(ref JsonReader reader, JsonSerializerOptions options)
        {
            if (reader.ReadIsNull())
            {
                throw new InvalidOperationException("type code is null, struct not supported");
            }

            reader.ReadIsBeginObjectWithVerify();
            var center = default(Vector3);
            var size   = default(Vector3);
            var count  = 0;

            while (!reader.ReadIsEndObjectWithSkipValueSeparator(ref count))
            {
                var stringKey = reader.ReadPropertyNameSegmentRaw();
                switch (stringKey.Length)
                {
                case 4:     // size
                    if (stringKey[0] != 's' || stringKey[1] != 'i' || stringKey[2] != 'z' || stringKey[3] != 'e')
                    {
                        goto default;
                    }

                    size = Vector3Formatter.DeserializeStatic(ref reader, options);
                    break;

                case 6:     // center
                    if (stringKey[0] != 'c' || stringKey[1] != 'e' || stringKey[2] != 'n' || stringKey[3] != 't' || stringKey[4] != 'e' || stringKey[5] != 'r')
                    {
                        goto default;
                    }

                    center = Vector3Formatter.DeserializeStatic(ref reader, options);
                    break;

                default:
                    reader.ReadNextBlock();
                    break;
                }
            }

            var answer = new Bounds(center, size);

            return(answer);
        }