New custom stream classes replacing BufferedStream and MemoryStream

Hi all,

Per discussion with @roji, I implemented some Stream classes to replace BufferedStream and MemoryStream, and got them working in Npgsql.

This is really preliminary work, and just the start of a much bigger project that I don't have time to finish, but i think it provides part of the basis needed for Npgsql to really take control of its buffer management.

i did not implement a buffer pool, which may prove to be another important aspect of this project, but a buffer pool is really quite trivial to write, and adapting NpgsqlMemoryStream to it would also be trivial.

The hard, tedious work ahead will lie in refactoring Npgsql to extend and use these new streams to eliminate a lot more allocations and copy operations, partly by taking advantage of the fact that we can have full access to their buffers.

-Glen

This is 1 more than the real max bytes per char for all encodings (except for UTF7), which might not be want we want. For example, for UTF8, this returns 4. But all chars can be encoded with at most 3 bytes. The reason it returns 1 more is that they assume you might want to use the Encoder class that can buffer 1 char in case of left over surrogate pairs between two calls to its Convert function.