public static Fill ( ReadCallback read, byte buffer, int offset, int count ) : void | ||
read | ReadCallback | |
buffer | byte | |
offset | int | |
count | int | |
Résultat | void |
public void ExceptionTest() { AsyncPump.Run( async() => { AssertThrow <ArgumentNullException>(() => StreamHelper.Fill(null, new byte[1], 0, 1)); await AssertThrowAsync <ArgumentNullException>( () => StreamHelper.FillAsync(null, new byte[1], 0, 1, CancellationToken.None)); }); }
/// <summary>Reads exactly <paramref name="count"/> bytes from the buffer.</summary> /// <exception cref="ArgumentException">The length of <paramref name="buffer"/> is less than /// <paramref name="offset"/> plus <paramref name="count"/>.</exception> /// <exception cref="ArgumentNullException"><paramref name="buffer"/> equals <c>null</c>.</exception> /// <exception cref="ArgumentOutOfRangeException"><paramref name="offset"/> and/or <paramref name="count"/> /// are negative.</exception> /// <exception cref="EndOfStreamException">The end of the stream has been reached before /// <paramref name="buffer"/> could be filled to <paramref name="count"/> bytes.</exception> /// <exception cref="InvalidOperationException">The <see cref="ReadBuffer"/> object was created by calling /// <see cref="ReadBuffer(ReadAsyncCallback, int)"/>.</exception> /// <remarks>If <paramref name="count"/> > <see cref="Count"/> - <see cref="Index"/> the callback specified /// during construction is called as necessary.</remarks> public void Fill(byte[] buffer, int offset, int count) { var readCount = this.ReadFromBuffer(buffer, offset, count); offset += readCount; count -= readCount; if (count > 0) { if (count > this.Capacity) { this.Compact(); StreamHelper.Fill(this.read, buffer, offset, count); this.previousPosition += count; } else { this.Fill(count); System.Buffer.BlockCopy(this.GetBuffer(), this.Index, buffer, offset, count); this.Index += count; } } }