Updated reactive extensions usage to reflect new changes

This commit is contained in:
LukePulverenti Luke Pulverenti luke pulverenti 2012-08-18 13:01:09 -04:00
parent 1e61debf2d
commit a201eb060b
3 changed files with 1 additions and 22 deletions

View File

@ -81,7 +81,6 @@
<Compile Include="Net\Handlers\BaseJsonHandler.cs" />
<Compile Include="Net\HttpServer.cs" />
<Compile Include="Net\Request.cs" />
<Compile Include="Net\StreamExtensions.cs" />
<Compile Include="Plugins\BasePlugin.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Serialization\XmlSerializer.cs" />

View File

@ -20,8 +20,7 @@ namespace MediaBrowser.Common.Net
private IObservable<HttpListenerContext> ObservableHttpContext()
{
return Observable.Create<HttpListenerContext>(obs =>
Observable.FromAsyncPattern<HttpListenerContext>(listener.BeginGetContext,
listener.EndGetContext)()
Observable.FromAsync<HttpListenerContext>(() => listener.GetContextAsync())
.Subscribe(obs))
.Repeat()
.Retry()

View File

@ -1,19 +0,0 @@
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;
})();
}
}
}