jellyfin/MediaBrowser.Net/StreamExtensions.cs
2012-07-19 22:22:44 -04:00

19 lines
520 B
C#

using System;
using System.IO;
using System.Reactive.Linq;
namespace MediaBrowser.Net
{
public static class StreamExtensions
{
public static IObservable<byte[]> ReadBytes(this Stream stream, int count)
{
var buffer = new byte[count];
return Observable.FromAsyncPattern((cb, state) => stream.BeginRead(buffer, 0, count, cb, state), ar =>
{
stream.EndRead(ar);
return buffer;
})();
}
}
}