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