Exemplo n.º 1
0
        public void Deserialize(ref TinyhandReader reader, TinyhandSerializerOptions options)
        {
            var numberOfData = reader.ReadArrayHeader();

            options.Security.DepthStep(ref reader);
            try
            {
                if (numberOfData-- > 0 && !reader.TryReadNil())
                {
                    this.X = options.Resolver.GetFormatter <int>().Deserialize(ref reader, options);
                }
                if (numberOfData-- > 0 && !reader.TryReadNil())
                {
                    this.Y = options.Resolver.GetFormatter <int>().Deserialize(ref reader, options);
                }
                if (numberOfData-- > 0 && !reader.TryReadNil())
                {
                    this.A = options.Resolver.GetFormatter <int[]>().Deserialize(ref reader, options) !;
                }
                else
                {
                    this.A = new int[0];
                }
                while (numberOfData-- > 0)
                {
                    reader.Skip();
                }
            }
            finally { reader.Depth--; }
        }
Exemplo n.º 2
0
        public static List <bool>?DeserializeBooleanList(ref TinyhandReader reader)
        {
            if (reader.TryReadNil())
            {
                return(null); // new List<bool>();
            }
            else
            {
                var len  = reader.ReadArrayHeader();
                var list = new List <bool>(len);
                for (int i = 0; i < len; i++)
                {
                    list.Add(reader.ReadBoolean());
                }

                return(list);
            }
        }
Exemplo n.º 3
0
        public static bool[]? DeserializeBooleanArray(ref TinyhandReader reader)
        {
            if (reader.TryReadNil())
            {
                return(null); // new bool[0];
            }
            else
            {
                var len   = reader.ReadArrayHeader();
                var array = new bool[len];
                for (int i = 0; i < array.Length; i++)
                {
                    array[i] = reader.ReadBoolean();
                }

                return(array);
            }
        }
Exemplo n.º 4
0
        public static double[]? DeserializeDoubleArray(ref TinyhandReader reader)
        {
            if (reader.TryReadNil())
            {
                return(null); // new double[0];
            }
            else
            {
                var len   = reader.ReadArrayHeader();
                var array = new double[len];
                for (int i = 0; i < array.Length; i++)
                {
                    array[i] = reader.ReadDouble();
                }

                return(array);
            }
        }
Exemplo n.º 5
0
        public static ulong[]? DeserializeUInt64Array(ref TinyhandReader reader)
        {
            if (reader.TryReadNil())
            {
                return(null); // new ulong[0];
            }
            else
            {
                var len   = reader.ReadArrayHeader();
                var array = new ulong[len];
                for (int i = 0; i < array.Length; i++)
                {
                    array[i] = reader.ReadUInt64();
                }

                return(array);
            }
        }
Exemplo n.º 6
0
        public static List <string>?DeserializeStringList(ref TinyhandReader reader)
        {
            if (reader.TryReadNil())
            {
                return(null); // new List<string>();
            }
            else
            {
                var len  = reader.ReadArrayHeader();
                var list = new List <string>(len);
                for (int i = 0; i < len; i++)
                {
                    list.Add(reader.ReadString() ?? string.Empty);
                }

                return(list);
            }
        }
Exemplo n.º 7
0
        public static string[]? DeserializeNullableStringArray(ref TinyhandReader reader)
        {
            if (reader.TryReadNil())
            {
                return(null); // new string[0];
            }
            else
            {
                var len   = reader.ReadArrayHeader();
                var array = new string[len];
                for (int i = 0; i < array.Length; i++)
                {
                    array[i] = reader.ReadString() ?? string.Empty;
                }

                return(array);
            }
        }