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()); }
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); }