fCraft.BufferUtil.ReadAll C# (CSharp) Метод

ReadAll() публичный статический Метод

Reads a number of bytes from source that matches the length of destination byte array.
source or destination is null. The end of stream is reached before destination array was filled.
public static ReadAll ( [ source, [ destination ) : void
source [ Stream to read from.
destination [ Byte array to write to. Length of this array is used.
Результат void
        public static void ReadAll( [NotNull] Stream source, [NotNull] byte[] destination ) {
            if( source == null ) throw new ArgumentNullException( "source" );
            if( destination == null ) throw new ArgumentNullException( "destination" );
            int bytesRead = 0;
            int bytesLeft = destination.Length;
            while( bytesLeft > 0 ) {
                int readPass = source.Read( destination, bytesRead, bytesLeft );
                if( readPass == 0 ) throw new EndOfStreamException();
                bytesRead += readPass;
                bytesLeft -= readPass;
            }
        }
    }