You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
527 B
19 lines
527 B
13 years ago
|
using System;
|
||
|
using System.IO;
|
||
|
using System.Reactive.Linq;
|
||
|
|
||
12 years ago
|
namespace MediaBrowser.Common.Net
|
||
13 years ago
|
{
|
||
|
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;
|
||
|
})();
|
||
|
}
|
||
|
}
|
||
|
}
|