mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-11-16 02:18:54 -07:00
19 lines
527 B
C#
19 lines
527 B
C#
using System;
|
|
using System.IO;
|
|
using System.Reactive.Linq;
|
|
|
|
namespace MediaBrowser.Common.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;
|
|
})();
|
|
}
|
|
}
|
|
} |