Skip to content

Instantly share code, notes, and snippets.

@benaadams
benaadams / Streams-MixinsAndCombines.cs
Last active November 26, 2015 23:25
Stream Evolution in Interfaces (Mixins+Streams)
// Interface segregation (Combined Mixin+Non-mixin)
// For no-mixins version see https://gist.github.com/benaadams/d35ff5c534a43fd6c89d
// For mixins/generic constraints version see https://gist.github.com/benaadams/77c6e7aa34aae92b876a
// Do something with sync Reading, Seeking, Disposable stream (Generic Constraints)
public static void DoSomething<T>(T stream) where T : IBlockingReader, ISeekable, ISizable, IDisposable
{
stream.ReadByte();
stream.SetLength(6);
stream.Position = 5;