Example #1
0
        T ITypeSerializer <T> .Deserialize(ref StreamingIterator iterator)
        {
            T result = new T();

            while (iterator.HasNext())
            {
                result.Add(iterator.NextAsWithoutTag <TValue>());
            }

            return(result);
        }
Example #2
0
        Type ITypeSerializer <Type> .Deserialize(ref StreamingIterator iterator)
        {
            if (!iterator.HasNext())
            {
                return(null);
            }

            string value = iterator.NextAsStringWithoutTag(Encoding.UTF8);

            return(Type.GetType(value, false));
        }
Example #3
0
        List <T> ITypeSerializer <List <T> > .Deserialize(ref StreamingIterator iterator)
        {
            int      count  = iterator.HasNext() ? iterator.NextAsInt32WithoutTag(NumberFormat.Variant) : 0;
            List <T> result = new List <T>(count);

            while (iterator.HasNext())
            {
                result.Add(iterator.NextAsWithoutTag <T>());
            }

            return(result);
        }
Example #4
0
        T[] ITypeSerializer <T[]> .Deserialize(ref StreamingIterator iterator)
        {
            int len = iterator.HasNext() ? iterator.NextAsInt32WithoutTag(NumberFormat.Variant) : 0;

            T[] result = new T[len];

            for (int i = 0; i < len && iterator.HasNext(); i++)
            {
                result[i] = iterator.NextAsWithoutTag <T>();
            }

            return(result);
        }
        T ITypeSerializer <T> .Deserialize(ref StreamingIterator iterator)
        {
            T result = new T();

            while (iterator.HasNext())
            {
                TKey   key   = iterator.NextAsWithoutTag <TKey>();
                TValue value = iterator.HasNext() ? iterator.NextAsWithoutTag <TValue>() : default;
                result.Add(key, value);
            }

            return(result);
        }
Example #6
0
        T ITypeSerializer <T> .Deserialize(ref StreamingIterator iterator)
        {
            int count = iterator.HasNext() ? iterator.NextAsInt32WithoutTag(NumberFormat.Variant) : 0;

            T result = new T();

            result.Initialize(count);

            while (iterator.HasNext())
            {
                result.Add(iterator.NextAsWithoutTag <TValue>());
            }

            return(result);
        }
Example #7
0
        Vector2Int ITypeSerializer <Vector2Int> .Deserialize(ref StreamingIterator iterator)
        {
            Vector2Int result = new Vector2Int();
            int        index  = 0;

            while (iterator.HasNext())
            {
                switch (index++)
                {
                case 0: result.x = iterator.NextAsInt32WithoutTag(NumberFormat.Variant); break;

                case 1: result.y = iterator.NextAsInt32WithoutTag(NumberFormat.Variant); break;

                default: return(result);
                }
            }

            return(result);
        }
Example #8
0
        Vector2 ITypeSerializer <Vector2> .Deserialize(ref StreamingIterator iterator)
        {
            Vector2 result = new Vector2();
            int     index  = 0;

            while (iterator.HasNext())
            {
                switch (index++)
                {
                case 0: result.x = iterator.NextAsFloat32WithoutTag(); break;

                case 1: result.y = iterator.NextAsFloat32WithoutTag(); break;

                default: return(result);
                }
            }

            return(result);
        }
Example #9
0
        Quaternion ITypeSerializer <Quaternion> .Deserialize(ref StreamingIterator iterator)
        {
            Quaternion result = new Quaternion();
            int        index  = 0;

            while (iterator.HasNext())
            {
                switch (index++)
                {
                case 0: result.x = iterator.NextAsFloat32WithoutTag(); break;

                case 1: result.y = iterator.NextAsFloat32WithoutTag(); break;

                case 2: result.z = iterator.NextAsFloat32WithoutTag(); break;

                case 3: result.w = iterator.NextAsFloat32WithoutTag(); break;

                default: return(result);
                }
            }

            return(result);
        }
        Dictionary <TKey, TValue> ITypeSerializer <Dictionary <TKey, TValue> > .Deserialize(ref StreamingIterator iterator)
        {
            int count = iterator.HasNext() ? iterator.NextAsInt32WithoutTag(NumberFormat.Variant) : 0;
            Dictionary <TKey, TValue> result = new Dictionary <TKey, TValue>(count);

            while (iterator.HasNext())
            {
                TKey   key   = iterator.NextAsWithoutTag <TKey>();
                TValue value = iterator.HasNext() ? iterator.NextAsWithoutTag <TValue>() : default;
                result.Add(key, value);
            }

            return(result);
        }
Example #11
0
 sbyte ITypeSerializer <sbyte> .Deserialize(ref StreamingIterator iterator)
 {
     return(iterator.HasNext() ? iterator.NextAsInt8WithoutTag(NumberFormat.Variant) : default);