Here are the examples of the csharp api System.IO.Stream.Read(Span) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
4 Examples
19
Source : Stream.cs
with MIT License
from dotnetGame
with MIT License
from dotnetGame
public virtual int Read(Span<byte> buffer)
{
byte[] sharedBuffer = ArrayPool<byte>.Shared.Rent(buffer.Length);
try
{
int numRead = Read(sharedBuffer, 0, buffer.Length);
if ((uint)numRead > buffer.Length)
{
throw new IOException(SR.IO_StreamTooLong);
}
new Span<byte>(sharedBuffer, 0, numRead).CopyTo(buffer);
return numRead;
}
finally { ArrayPool<byte>.Shared.Return(sharedBuffer); }
}
19
Source : Stream.cs
with MIT License
from dotnetGame
with MIT License
from dotnetGame
public override int Read(Span<byte> buffer)
{
lock (_stream)
return _stream.Read(buffer);
}
19
Source : Stream.cs
with MIT License
from Team-RTCLI
with MIT License
from Team-RTCLI
public virtual int Read(Span<byte> buffer)
{
byte[] sharedBuffer = ArrayPool<byte>.Shared.Rent(buffer.Length);
try
{
int numRead = Read(sharedBuffer, 0, buffer.Length);
if ((uint)numRead > (uint)buffer.Length)
{
throw new IOException(SR.IO_StreamTooLong);
}
new ReadOnlySpan<byte>(sharedBuffer, 0, numRead).CopyTo(buffer);
return numRead;
}
finally
{
ArrayPool<byte>.Shared.Return(sharedBuffer);
}
}
19
Source : Stream.cs
with MIT License
from Team-RTCLI
with MIT License
from Team-RTCLI
public override int Read(Span<byte> buffer)
{
lock (_stream)
{
return _stream.Read(buffer);
}
}