Пример #1
0
        T[] ReadWithoutLength(IArrayDataReader reader, IServiceProvider serviceProvider)
        {
            var itemSerializer = Factory.GetSerializer <T>(serviceProvider);
            var buffer         = new List <T>();

            while (reader.MoveNext())
            {
                buffer.Add(itemSerializer.Read(reader, serviceProvider));
            }
            return(buffer.ToArray());
        }
Пример #2
0
        T[] ReadWithLength(IArrayDataReader reader, int arrayLength, IServiceProvider serviceProvider)
        {
            var itemSerializer = Factory.GetSerializer <T>(serviceProvider);
            var array          = new T[arrayLength];

            for (var i = 0; i < arrayLength; ++i)
            {
                if (!reader.MoveNext())
                {
                    throw new SerializationException("Unexpected end of array");
                }
                array[i] = itemSerializer.Read(reader, serviceProvider);
            }
            return(array);
        }