Browse files

Merge branch 'master' into reactiveui.mobile

  • Loading branch information...
2 parents 05a1286 + 15adbad commit 184f6f09102b763088385c2b0f555f40c22bcd16 @paulcbetts paulcbetts committed Dec 16, 2012
Showing with 699 additions and 66 deletions.
  1. +1 −1 NuGet/ReactiveUI-Core/ReactiveUI-Core.nuspec
  2. 0 NuGet/ReactiveUI-Core/lib/WP8/System.Reactive.Providers.dll
  3. 0 NuGet/ReactiveUI-Core/lib/WP8/System.Reactive.Providers.xml
  4. 0 .../{ReactiveUI-Xaml/lib/net45/ReactiveUI.Xaml.xml → ReactiveUI-Core/lib/net45/ReactiveUI_Net45.dll}
  5. 0 .../{ReactiveUI-Xaml/lib/net45/ReactiveUI.Xaml.pdb → ReactiveUI-Core/lib/net45/ReactiveUI_Net45.pdb}
  6. 0 .../{ReactiveUI-Xaml/lib/net45/ReactiveUI.Xaml.dll → ReactiveUI-Core/lib/net45/ReactiveUI_Net45.xml}
  7. +2 −2 NuGet/ReactiveUI-NLog/ReactiveUI-NLog.nuspec
  8. 0 ...veUI-Xaml/lib/net45/ReactiveUI.Routing.pdb → ReactiveUI-NLog/lib/net45/ReactiveUI.NLog_Net45.dll}
  9. 0 ...veUI-Xaml/lib/net45/ReactiveUI.Routing.dll → ReactiveUI-NLog/lib/net45/ReactiveUI.NLog_Net45.pdb}
  10. 0 ...veUI-Xaml/lib/net45/ReactiveUI.Routing.XML → ReactiveUI-NLog/lib/net45/ReactiveUI.NLog_Net45.xml}
  11. +2 −2 NuGet/ReactiveUI-Testing/ReactiveUI-Testing.nuspec
  12. 0 ...-Xaml/lib/net45/ReactiveUI.Blend.xml → ReactiveUI-Testing/lib/net45/ReactiveUI.Testing_Net45.dll}
  13. 0 ...-Xaml/lib/net45/ReactiveUI.Blend.pdb → ReactiveUI-Testing/lib/net45/ReactiveUI.Testing_Net45.pdb}
  14. 0 ...-Xaml/lib/net45/ReactiveUI.Blend.dll → ReactiveUI-Testing/lib/net45/ReactiveUI.Testing_Net45.xml}
  15. +3 −3 NuGet/ReactiveUI-WinRT/ReactiveUI-WinRT.nuspec
  16. +2 −2 NuGet/ReactiveUI-Xaml/ReactiveUI-Xaml.nuspec
  17. 0 ...-Testing/lib/net45/ReactiveUI.Testing.xml → ReactiveUI-Xaml/lib/net45/ReactiveUI.Blend_Net45.dll}
  18. 0 ...-Testing/lib/net45/ReactiveUI.Testing.pdb → ReactiveUI-Xaml/lib/net45/ReactiveUI.Blend_Net45.pdb}
  19. 0 ...-Testing/lib/net45/ReactiveUI.Testing.dll → ReactiveUI-Xaml/lib/net45/ReactiveUI.Blend_Net45.xml}
  20. 0 ...veUI-NLog/lib/net45/ReactiveUI.NLog.xml → ReactiveUI-Xaml/lib/net45/ReactiveUI.Routing_Net45.XML}
  21. 0 ...veUI-NLog/lib/net45/ReactiveUI.NLog.pdb → ReactiveUI-Xaml/lib/net45/ReactiveUI.Routing_Net45.dll}
  22. 0 ...veUI-NLog/lib/net45/ReactiveUI.NLog.dll → ReactiveUI-Xaml/lib/net45/ReactiveUI.Routing_Net45.pdb}
  23. 0 .../{ReactiveUI-Core/lib/net45/ReactiveUI.xml → ReactiveUI-Xaml/lib/net45/ReactiveUI.Xaml_Net45.dll}
  24. 0 .../{ReactiveUI-Core/lib/net45/ReactiveUI.pdb → ReactiveUI-Xaml/lib/net45/ReactiveUI.Xaml_Net45.pdb}
  25. 0 .../{ReactiveUI-Core/lib/net45/ReactiveUI.dll → ReactiveUI-Xaml/lib/net45/ReactiveUI.Xaml_Net45.xml}
  26. +4 −5 NuGet/ReactiveUI/ReactiveUI.nuspec
  27. +3 −3 README.md
  28. +1 −1 ReactiveUI.Blend/Properties/AssemblyInfo.cs
  29. +1 −1 ReactiveUI.Gtk/Properties/AssemblyInfo.cs
  30. +1 −1 ReactiveUI.Routing/Properties/AssemblyInfo.cs
  31. +1 −1 ReactiveUI.Serialization.Esent/Properties/AssemblyInfo.cs
  32. +1 −1 ReactiveUI.Serialization/Properties/AssemblyInfo.cs
  33. +1 −1 ReactiveUI.Testing/Properties/AssemblyInfo.cs
  34. +34 −0 ReactiveUI.Tests/AwaiterTest.cs
  35. +16 −0 ReactiveUI.Tests/ReactiveUI.Tests.csproj
  36. +20 −1 ReactiveUI.Tests/ReactiveUI.Tests_SL5.csproj
  37. +5 −0 ReactiveUI.Tests/packages.config
  38. +1 −1 ReactiveUI.Xaml/Properties/AssemblyInfo.cs
  39. +19 −1 ReactiveUI.Xaml/ReactiveAsyncCommand.cs
  40. +42 −26 ReactiveUI.Xaml/ReactiveCommand.cs
  41. +5 −1 ReactiveUI.sln
  42. +1 −1 ReactiveUI/BindingTypeConverters.cs
  43. +3 −4 ReactiveUI/MessageBus.cs
  44. +1 −1 ReactiveUI/Properties/AssemblyInfo.cs
  45. +7 −1 ReactiveUI/ReactiveUI.csproj
  46. +4 −0 ReactiveUI/ReactiveUI_SL5.csproj
  47. +4 −0 ReactiveUI/ReactiveUI_WP7.csproj
  48. +4 −0 ReactiveUI/ReactiveUI_WP8.csproj
  49. +6 −1 ReactiveUI/ReactiveUI_WinRT.csproj
  50. +342 −0 ReactiveUI/Rx-Shim/AwaitableAsyncSubject.cs
  51. +69 −0 ReactiveUI/Rx-Shim/GetAwaiter.cs
  52. +60 −0 ReactiveUI/Rx-Shim/ImmutableList.cs
  53. +15 −0 ReactiveUI/Rx-Shim/LICENSE
  54. +11 −2 ReactiveUI/RxApp.cs
  55. +5 −0 ReactiveUI/packages.config
  56. +2 −2 packages/repositories.config
View
2 NuGet/ReactiveUI-Core/ReactiveUI-Core.nuspec
@@ -2,7 +2,7 @@
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>reactiveui-core</id>
- <version>4.1.0</version>
+ <version>4.2.1</version>
<description>An MVVM library for .NET that is deeply integrated with the Reactive Extensions</description>
<authors>Paul Betts</authors>
<projectUrl>http://www.reactiveui.net</projectUrl>
View
0 NuGet/ReactiveUI-Core/lib/WP8/System.Reactive.Providers.dll
No changes.
View
0 NuGet/ReactiveUI-Core/lib/WP8/System.Reactive.Providers.xml
No changes.
View
0 ...tiveUI-Xaml/lib/net45/ReactiveUI.Xaml.xml → ...iveUI-Core/lib/net45/ReactiveUI_Net45.dll
File renamed without changes.
View
0 ...tiveUI-Xaml/lib/net45/ReactiveUI.Xaml.pdb → ...iveUI-Core/lib/net45/ReactiveUI_Net45.pdb
File renamed without changes.
View
0 ...tiveUI-Xaml/lib/net45/ReactiveUI.Xaml.dll → ...iveUI-Core/lib/net45/ReactiveUI_Net45.xml
File renamed without changes.
View
4 NuGet/ReactiveUI-NLog/ReactiveUI-NLog.nuspec
@@ -2,7 +2,7 @@
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>reactiveui-nlog</id>
- <version>4.1.0</version>
+ <version>4.2.1</version>
<description>An adapter to initialize NLog as the logger for ReactiveUI.</description>
<authors>Paul Betts</authors>
<projectUrl>http://www.reactiveui.net</projectUrl>
@@ -11,7 +11,7 @@
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<dependencies>
- <dependency id="reactiveui-core" version="[4.1.0]" />
+ <dependency id="reactiveui-core" version="[4.2.1]" />
<dependency id="NLog" version="2.0.0.2000" />
</dependencies>
</metadata>
View
0 ...eUI-Xaml/lib/net45/ReactiveUI.Routing.pdb → ...-NLog/lib/net45/ReactiveUI.NLog_Net45.dll
File renamed without changes.
View
0 ...eUI-Xaml/lib/net45/ReactiveUI.Routing.dll → ...-NLog/lib/net45/ReactiveUI.NLog_Net45.pdb
File renamed without changes.
View
0 ...eUI-Xaml/lib/net45/ReactiveUI.Routing.XML → ...-NLog/lib/net45/ReactiveUI.NLog_Net45.xml
File renamed without changes.
View
4 NuGet/ReactiveUI-Testing/ReactiveUI-Testing.nuspec
@@ -2,7 +2,7 @@
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>reactiveui-testing</id>
- <version>4.1.0</version>
+ <version>4.2.1</version>
<description>A library to aid in writing unit tests for ReactiveUI projects</description>
<authors>Paul Betts</authors>
<projectUrl>http://www.reactiveui.net</projectUrl>
@@ -11,7 +11,7 @@
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<dependencies>
- <dependency id="reactiveui-core" version="[4.1.0]" />
+ <dependency id="reactiveui-core" version="[4.2.1]" />
<dependency id="Rx-Testing" version="[2.0.21114]" />
</dependencies>
</metadata>
View
0 ...iveUI-Xaml/lib/net45/ReactiveUI.Blend.xml → ...ng/lib/net45/ReactiveUI.Testing_Net45.dll
File renamed without changes.
View
0 ...iveUI-Xaml/lib/net45/ReactiveUI.Blend.pdb → ...ng/lib/net45/ReactiveUI.Testing_Net45.pdb
File renamed without changes.
View
0 ...iveUI-Xaml/lib/net45/ReactiveUI.Blend.dll → ...ng/lib/net45/ReactiveUI.Testing_Net45.xml
File renamed without changes.
View
6 NuGet/ReactiveUI-WinRT/ReactiveUI-WinRT.nuspec
@@ -2,7 +2,7 @@
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>reactiveui-winrt</id>
- <version>4.1.0</version>
+ <version>4.2.1</version>
<description>An MVVM library for WPF and Silverlight that is deeply integrated with the Reactive Extensions</description>
<authors>Paul Betts</authors>
<projectUrl>http://www.reactiveui.net</projectUrl>
@@ -11,8 +11,8 @@
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<dependencies>
- <dependency id="reactiveui-core" version="[4.1.0]" />
- <dependency id="reactiveui-xaml" version="[4.1.0]" />
+ <dependency id="reactiveui-core" version="[4.2.1]" />
+ <dependency id="reactiveui-xaml" version="[4.2.1]" />
<dependency id="Rx-WinRT" version="[2.0.21114]" />
</dependencies>
</metadata>
View
4 NuGet/ReactiveUI-Xaml/ReactiveUI-Xaml.nuspec
@@ -2,7 +2,7 @@
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>reactiveui-xaml</id>
- <version>4.1.0</version>
+ <version>4.2.1</version>
<description>WPF and Silverlight specific extensions to ReactiveUI</description>
<authors>Paul Betts</authors>
<projectUrl>http://www.reactiveui.net</projectUrl>
@@ -11,7 +11,7 @@
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<dependencies>
- <dependency id="reactiveui-core" version="[4.1.0]" />
+ <dependency id="reactiveui-core" version="[4.2.1]" />
<dependency id="Rx-Xaml" version="[2.0.21114]" />
</dependencies>
</metadata>
View
0 ...-Testing/lib/net45/ReactiveUI.Testing.xml → ...Xaml/lib/net45/ReactiveUI.Blend_Net45.dll
File renamed without changes.
View
0 ...-Testing/lib/net45/ReactiveUI.Testing.pdb → ...Xaml/lib/net45/ReactiveUI.Blend_Net45.pdb
File renamed without changes.
View
0 ...-Testing/lib/net45/ReactiveUI.Testing.dll → ...Xaml/lib/net45/ReactiveUI.Blend_Net45.xml
File renamed without changes.
View
0 ...tiveUI-NLog/lib/net45/ReactiveUI.NLog.xml → ...ml/lib/net45/ReactiveUI.Routing_Net45.XML
File renamed without changes.
View
0 ...tiveUI-NLog/lib/net45/ReactiveUI.NLog.pdb → ...ml/lib/net45/ReactiveUI.Routing_Net45.dll
File renamed without changes.
View
0 ...tiveUI-NLog/lib/net45/ReactiveUI.NLog.dll → ...ml/lib/net45/ReactiveUI.Routing_Net45.pdb
File renamed without changes.
View
0 .../ReactiveUI-Core/lib/net45/ReactiveUI.xml → ...-Xaml/lib/net45/ReactiveUI.Xaml_Net45.dll
File renamed without changes.
View
0 .../ReactiveUI-Core/lib/net45/ReactiveUI.pdb → ...-Xaml/lib/net45/ReactiveUI.Xaml_Net45.pdb
File renamed without changes.
View
0 .../ReactiveUI-Core/lib/net45/ReactiveUI.dll → ...-Xaml/lib/net45/ReactiveUI.Xaml_Net45.xml
File renamed without changes.
View
9 NuGet/ReactiveUI/ReactiveUI.nuspec
@@ -2,7 +2,7 @@
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>reactiveui</id>
- <version>4.1.0</version>
+ <version>4.2.1</version>
<description>An MVVM library for WPF and Silverlight that is deeply integrated with the Reactive Extensions</description>
<authors>Paul Betts</authors>
<projectUrl>http://www.reactiveui.net</projectUrl>
@@ -11,10 +11,9 @@
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<dependencies>
- <dependency id="reactiveui-core" version="[4.1.0]" />
- <dependency id="reactiveui-nlog" version="[4.1.0]" />
- <dependency id="reactiveui-xaml" version="[4.1.0]" />
- <dependency id="reactiveui-testing" version="[4.1.0]" />
+ <dependency id="reactiveui-core" version="[4.2.1]" />
+ <dependency id="reactiveui-nlog" version="[4.2.1]" />
+ <dependency id="reactiveui-xaml" version="[4.2.1]" />
</dependencies>
</metadata>
</package>
View
6 README.md
@@ -33,19 +33,19 @@ public class ColorChooserThatDoesntLikeGreen : ReactiveObject
byte _Red;
public byte Red {
get { return _Red; }
- set { this.RaiseAndSetIfChanged(x => x.Red, value); }
+ set { this.RaiseAndSetIfChanged(value); }
}
byte _Green;
public byte Green {
get { return _Green; }
- set { this.RaiseAndSetIfChanged(x => x.Green, value); }
+ set { this.RaiseAndSetIfChanged(value); }
}
byte _Blue;
public byte Blue {
get { return _Blue; }
- set { this.RaiseAndSetIfChanged(x => x.Blue, value); }
+ set { this.RaiseAndSetIfChanged(value); }
}
//
View
2 ReactiveUI.Blend/Properties/AssemblyInfo.cs
@@ -3,4 +3,4 @@
[assembly: AssemblyDescription("An MVVM framework that integrates the Reactive Extensions")]
[assembly: AssemblyProduct("ReactiveUI for Expression Blend")]
-[assembly: AssemblyVersion("4.1.0")]
+[assembly: AssemblyVersion("4.2.1")]
View
2 ReactiveUI.Gtk/Properties/AssemblyInfo.cs
@@ -8,4 +8,4 @@
[assembly: AssemblyDescription("Gtk# support for ReactiveUI")]
[assembly: AssemblyProduct("ReactiveUI.Gtk")]
-[assembly: AssemblyVersion("4.1.0")]
+[assembly: AssemblyVersion("4.2.1")]
View
2 ReactiveUI.Routing/Properties/AssemblyInfo.cs
@@ -9,6 +9,6 @@
[assembly: AssemblyDescription("A ViewModel-based Routing framework for RxUI")]
[assembly: AssemblyProduct("ReactiveUI.Routing")]
-[assembly: AssemblyVersion("4.1.0")]
+[assembly: AssemblyVersion("4.2.1")]
[assembly: InternalsVisibleTo("ReactiveUI.Routing.Tests")]
[assembly: InternalsVisibleTo("ReactiveUI.Routing.Explorables")]
View
2 ReactiveUI.Serialization.Esent/Properties/AssemblyInfo.cs
@@ -8,4 +8,4 @@
[assembly: AssemblyTitle("ReactiveUI.Serialization.Esent")]
[assembly: AssemblyDescription("ESENT-based storage provider for ReactiveUI.Serialization")]
[assembly: AssemblyProduct("ReactiveUI.Serialization")]
-[assembly: AssemblyVersion("4.1.0")]
+[assembly: AssemblyVersion("4.2.1")]
View
2 ReactiveUI.Serialization/Properties/AssemblyInfo.cs
@@ -9,6 +9,6 @@
[assembly: AssemblyDescription("A key-value based serialization library for ReactiveUI")]
[assembly: AssemblyProduct("ReactiveUI.Serialization")]
-[assembly: AssemblyVersion("4.1.0")]
+[assembly: AssemblyVersion("4.2.1")]
[assembly: InternalsVisibleTo("ReactiveUI.Serialization.Tests")]
[assembly: InternalsVisibleTo("ReactiveUI.Serialization.Explorables")]
View
2 ReactiveUI.Testing/Properties/AssemblyInfo.cs
@@ -4,4 +4,4 @@
[assembly: AssemblyDescription("Classes that aid in testing ReactiveUI projects")]
[assembly: AssemblyProduct("ReactiveUI.Testing")]
-[assembly: AssemblyVersion("4.1.0")]
+[assembly: AssemblyVersion("4.2.1")]
View
34 ReactiveUI.Tests/AwaiterTest.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reactive.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace ReactiveUI.Tests
+{
+ public class AwaiterTest
+ {
+ [Fact]
+ public void AwaiterSmokeTest()
+ {
+ var fixture = awaitAnObservable();
+ fixture.Wait();
+
+ Assert.Equal(42, fixture.Result);
+ }
+
+ async Task<int> awaitAnObservable()
+ {
+ var o = Observable.Start(() => {
+ Thread.Sleep(1000);
+ return 42;
+ }, RxApp.TaskpoolScheduler);
+
+ var ret = await o;
+ return ret;
+ }
+ }
+}
View
16 ReactiveUI.Tests/ReactiveUI.Tests.csproj
@@ -48,6 +48,15 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\ext\Microsoft.Reactive.Testing.dll</HintPath>
</Reference>
+ <Reference Include="Microsoft.Threading.Tasks">
+ <HintPath>..\packages\Microsoft.Bcl.Async.1.0.12-beta\lib\net40\Microsoft.Threading.Tasks.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.Threading.Tasks.Extensions">
+ <HintPath>..\packages\Microsoft.Bcl.Async.1.0.12-beta\lib\net40\Microsoft.Threading.Tasks.Extensions.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.Threading.Tasks.Extensions.Desktop">
+ <HintPath>..\packages\Microsoft.Bcl.Async.1.0.12-beta\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll</HintPath>
+ </Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
@@ -75,7 +84,13 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\ext\System.Reactive.Windows.Threading.dll</HintPath>
</Reference>
+ <Reference Include="System.Runtime">
+ <HintPath>..\packages\Microsoft.Bcl.1.0.11-beta\lib\net40\System.Runtime.dll</HintPath>
+ </Reference>
<Reference Include="System.Runtime.Serialization" />
+ <Reference Include="System.Threading.Tasks">
+ <HintPath>..\packages\Microsoft.Bcl.1.0.11-beta\lib\net40\System.Threading.Tasks.dll</HintPath>
+ </Reference>
<Reference Include="System.Xaml" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
@@ -93,6 +108,7 @@
</CodeAnalysisDependentAssemblyPaths>
</ItemGroup>
<ItemGroup>
+ <Compile Include="AwaiterTest.cs" />
<Compile Include="BindingTypeConvertersTest.cs" />
<Compile Include="CommandBindingTests.cs" />
<Compile Include="DependencyObjectObservableForPropertyTest.cs" />
View
21 ReactiveUI.Tests/ReactiveUI.Tests_SL5.csproj
@@ -82,6 +82,15 @@
<Reference Include="Microsoft.Silverlight.Testing">
<HintPath>..\ext\SL5\Microsoft.Silverlight.Testing.dll</HintPath>
</Reference>
+ <Reference Include="Microsoft.Threading.Tasks">
+ <HintPath>..\packages\Microsoft.Bcl.Async.1.0.12-beta\lib\sl5\Microsoft.Threading.Tasks.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.Threading.Tasks.Extensions">
+ <HintPath>..\packages\Microsoft.Bcl.Async.1.0.12-beta\lib\sl5\Microsoft.Threading.Tasks.Extensions.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.Threading.Tasks.Extensions.Silverlight">
+ <HintPath>..\packages\Microsoft.Bcl.Async.1.0.12-beta\lib\sl5\Microsoft.Threading.Tasks.Extensions.Silverlight.dll</HintPath>
+ </Reference>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight">
<HintPath>..\ext\SL5\Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll</HintPath>
</Reference>
@@ -106,9 +115,17 @@
<HintPath>..\ext\SL5\System.Reactive.Windows.Threading.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel.DataAnnotations, Version=5.0.5.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217, processorArchitecture=MSIL" />
+ <Reference Include="System.Runtime, Version=2.5.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\packages\Microsoft.Bcl.1.0.11-beta\lib\sl5\System.Runtime.dll</HintPath>
+ </Reference>
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Runtime.Serialization.Json, Version=5.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="System.ServiceModel.Web" />
+ <Reference Include="System.Threading.Tasks, Version=2.5.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\packages\Microsoft.Bcl.1.0.11-beta\lib\sl5\System.Threading.Tasks.dll</HintPath>
+ </Reference>
<Reference Include="System.Windows" />
<Reference Include="mscorlib" />
<Reference Include="system" />
@@ -156,6 +173,7 @@
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
+ <None Include="packages.config" />
<None Include="Properties\AppManifest.xml">
<SubType>Designer</SubType>
</None>
@@ -189,4 +207,5 @@
</VisualStudio>
</ProjectExtensions>
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
-</Project>
+ <Import Project="..\packages\Microsoft.Bcl.1.0.11-beta\tools\portable-net40+sl4+win8+wp71\Microsoft.Bcl.targets" />
+</Project>
View
5 ReactiveUI.Tests/packages.config
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="Microsoft.Bcl" version="1.0.11-beta" targetFramework="sl50" />
+ <package id="Microsoft.Bcl.Async" version="1.0.12-beta" targetFramework="sl50" />
+</packages>
View
2 ReactiveUI.Xaml/Properties/AssemblyInfo.cs
@@ -5,7 +5,7 @@
[assembly: AssemblyDescription("An MVVM framework that integrates the Reactive Extensions")]
[assembly: AssemblyProduct("ReactiveUI.Xaml")]
-[assembly: AssemblyVersion("4.1.0")]
+[assembly: AssemblyVersion("4.2.1")]
#if !(WINRT || SILVERLIGHT || MONO)
[assembly: ThemeInfo(
View
20 ReactiveUI.Xaml/ReactiveAsyncCommand.cs
@@ -161,7 +161,11 @@ public void Execute(object parameter)
public IDisposable Subscribe(IObserver<object> observer)
{
- return _executeSubject.Subscribe(observer);
+ return _executeSubject.Subscribe(
+ Observer.Create<object>(
+ x => marshalFailures(observer.OnNext, x),
+ ex => marshalFailures(observer.OnError, ex),
+ () => marshalFailures(observer.OnCompleted)));
}
public void Dispose()
@@ -337,6 +341,20 @@ public IObservable<TResult> RegisterAsyncObservable<TResult>(Func<object, IObser
calculationFunc, maxSize, _maximumConcurrent, onRelease, sched);
return this.RegisterAsyncObservable(cache.AsyncGet);
}
+
+ void marshalFailures<T>(Action<T> block, T param)
+ {
+ try {
+ block(param);
+ } catch (Exception ex) {
+ _exSubject.OnNext(ex);
+ }
+ }
+
+ void marshalFailures(Action block)
+ {
+ marshalFailures(_ => block(), Unit.Default);
+ }
}
public static class ReactiveAsyncCommandMixins
View
68 ReactiveUI.Xaml/ReactiveCommand.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Reactive;
using System.Reactive.Concurrency;
using System.Reactive.Linq;
using System.Reactive.Subjects;
@@ -33,33 +34,27 @@ public ReactiveCommand(IObservable<bool> canExecute = null, IScheduler scheduler
canExecute = canExecute.ObserveOn(scheduler ?? RxApp.DeferredScheduler);
commonCtor(scheduler);
- var exSubject = new ScheduledSubject<Exception>(RxApp.DeferredScheduler, RxApp.DefaultExceptionHandler);
-
_inner = canExecute.Subscribe(
- canExecuteSubject.OnNext,
- exSubject.OnNext);
+ _canExecuteSubject.OnNext,
+ _exSubject.OnNext);
- ThrownExceptions = exSubject;
+ ThrownExceptions = _exSubject;
}
protected ReactiveCommand(Func<object, Task<bool>> canExecuteFunc, IScheduler scheduler = null)
{
- var canExecute = canExecuteProbed.SelectMany(x => canExecuteFunc(x).ToObservable());
+ var canExecute = _canExecuteProbed.SelectMany(x => canExecuteFunc(x).ToObservable());
commonCtor(scheduler);
- var exSubject = new ScheduledSubject<Exception>(RxApp.DeferredScheduler, RxApp.DefaultExceptionHandler);
-
_inner = canExecute.Subscribe(
- canExecuteSubject.OnNext,
- exSubject.OnNext);
-
- ThrownExceptions = exSubject;
+ _canExecuteSubject.OnNext,
+ _exSubject.OnNext);
}
protected ReactiveCommand(Func<object, bool> canExecute, IScheduler scheduler = null)
{
- canExecuteExplicitFunc = canExecute;
+ _canExecuteExplicitFunc = canExecute;
commonCtor(scheduler);
}
@@ -118,35 +113,38 @@ void commonCtor(IScheduler scheduler)
{
this.scheduler = scheduler ?? RxApp.DeferredScheduler;
- canExecuteSubject = new ScheduledSubject<bool>(RxApp.DeferredScheduler);
- canExecuteLatest = new ObservableAsPropertyHelper<bool>(canExecuteSubject,
+ _canExecuteSubject = new ScheduledSubject<bool>(RxApp.DeferredScheduler);
+ canExecuteLatest = new ObservableAsPropertyHelper<bool>(_canExecuteSubject,
b => { if (CanExecuteChanged != null) CanExecuteChanged(this, EventArgs.Empty); },
true, scheduler);
- canExecuteProbed = new Subject<object>();
+ _canExecuteProbed = new Subject<object>();
executeSubject = new Subject<object>();
+
+ _exSubject = new ScheduledSubject<Exception>(RxApp.DeferredScheduler, RxApp.DefaultExceptionHandler);
+ ThrownExceptions = _exSubject;
}
- Func<object, bool> canExecuteExplicitFunc;
- protected ISubject<bool> canExecuteSubject;
- protected Subject<object> canExecuteProbed;
+ Func<object, bool> _canExecuteExplicitFunc;
+ protected ISubject<bool> _canExecuteSubject;
+ protected Subject<object> _canExecuteProbed;
IDisposable _inner = null;
-
+ ScheduledSubject<Exception> _exSubject;
/// <summary>
/// Fires whenever the CanExecute of the ICommand changes.
/// </summary>
public IObservable<bool> CanExecuteObservable {
- get { return canExecuteSubject.DistinctUntilChanged(); }
+ get { return _canExecuteSubject.DistinctUntilChanged(); }
}
ObservableAsPropertyHelper<bool> canExecuteLatest;
public virtual bool CanExecute(object parameter)
{
- canExecuteProbed.OnNext(parameter);
- if (canExecuteExplicitFunc != null) {
- bool ret = canExecuteExplicitFunc(parameter);
- canExecuteSubject.OnNext(ret);
+ _canExecuteProbed.OnNext(parameter);
+ if (_canExecuteExplicitFunc != null) {
+ bool ret = _canExecuteExplicitFunc(parameter);
+ _canExecuteSubject.OnNext(ret);
return ret;
}
@@ -166,7 +164,11 @@ public void Execute(object parameter)
public IDisposable Subscribe(IObserver<object> observer)
{
- return executeSubject.ObserveOn(scheduler).Subscribe(observer);
+ return executeSubject.ObserveOn(scheduler).Subscribe(
+ Observer.Create<object>(
+ x => marshalFailures(observer.OnNext, x),
+ ex => marshalFailures(observer.OnError, ex),
+ () => marshalFailures(observer.OnCompleted)));
}
public void Dispose()
@@ -175,6 +177,20 @@ public void Dispose()
_inner.Dispose();
}
}
+
+ void marshalFailures<T>(Action<T> block, T param)
+ {
+ try {
+ block(param);
+ } catch (Exception ex) {
+ _exSubject.OnNext(ex);
+ }
+ }
+
+ void marshalFailures(Action block)
+ {
+ marshalFailures(_ => block(), Unit.Default);
+ }
}
public static class ReactiveCommandMixins
View
6 ReactiveUI.sln
@@ -134,6 +134,7 @@ Global
{B3381C78-C099-4902-89D4-B879AA83BFC9}.Debug|x64.ActiveCfg = Debug|Any CPU
{B3381C78-C099-4902-89D4-B879AA83BFC9}.Debug|x86.ActiveCfg = Debug|Any CPU
{B3381C78-C099-4902-89D4-B879AA83BFC9}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B3381C78-C099-4902-89D4-B879AA83BFC9}.Release|Any CPU.Build.0 = Release|Any CPU
{B3381C78-C099-4902-89D4-B879AA83BFC9}.Release|ARM.ActiveCfg = Release|Any CPU
{B3381C78-C099-4902-89D4-B879AA83BFC9}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{B3381C78-C099-4902-89D4-B879AA83BFC9}.Release|Mixed Platforms.Build.0 = Release|Any CPU
@@ -161,6 +162,7 @@ Global
{1E453720-AEE5-4B34-8660-7AD86E5E05AF}.Debug|x64.ActiveCfg = Debug|Any CPU
{1E453720-AEE5-4B34-8660-7AD86E5E05AF}.Debug|x86.ActiveCfg = Debug|Any CPU
{1E453720-AEE5-4B34-8660-7AD86E5E05AF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1E453720-AEE5-4B34-8660-7AD86E5E05AF}.Release|Any CPU.Build.0 = Release|Any CPU
{1E453720-AEE5-4B34-8660-7AD86E5E05AF}.Release|ARM.ActiveCfg = Release|Any CPU
{1E453720-AEE5-4B34-8660-7AD86E5E05AF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{1E453720-AEE5-4B34-8660-7AD86E5E05AF}.Release|Mixed Platforms.Build.0 = Release|Any CPU
@@ -202,6 +204,7 @@ Global
{007E6D54-44FE-45BA-A364-AD108B7C6CDF}.Debug|x64.ActiveCfg = Debug|Any CPU
{007E6D54-44FE-45BA-A364-AD108B7C6CDF}.Debug|x86.ActiveCfg = Debug|Any CPU
{007E6D54-44FE-45BA-A364-AD108B7C6CDF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {007E6D54-44FE-45BA-A364-AD108B7C6CDF}.Release|Any CPU.Build.0 = Release|Any CPU
{007E6D54-44FE-45BA-A364-AD108B7C6CDF}.Release|ARM.ActiveCfg = Release|Any CPU
{007E6D54-44FE-45BA-A364-AD108B7C6CDF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{007E6D54-44FE-45BA-A364-AD108B7C6CDF}.Release|Mixed Platforms.Build.0 = Release|Any CPU
@@ -229,6 +232,7 @@ Global
{73804A79-A9FC-48FD-8F7C-E796415A8B3A}.Debug|x64.ActiveCfg = Debug|Any CPU
{73804A79-A9FC-48FD-8F7C-E796415A8B3A}.Debug|x86.ActiveCfg = Debug|Any CPU
{73804A79-A9FC-48FD-8F7C-E796415A8B3A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {73804A79-A9FC-48FD-8F7C-E796415A8B3A}.Release|Any CPU.Build.0 = Release|Any CPU
{73804A79-A9FC-48FD-8F7C-E796415A8B3A}.Release|ARM.ActiveCfg = Release|Any CPU
{73804A79-A9FC-48FD-8F7C-E796415A8B3A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{73804A79-A9FC-48FD-8F7C-E796415A8B3A}.Release|Mixed Platforms.Build.0 = Release|Any CPU
@@ -270,6 +274,7 @@ Global
{435E1011-E9FE-4E61-8B6D-2627DC6D1F06}.Debug|x64.ActiveCfg = Debug|Any CPU
{435E1011-E9FE-4E61-8B6D-2627DC6D1F06}.Debug|x86.ActiveCfg = Debug|Any CPU
{435E1011-E9FE-4E61-8B6D-2627DC6D1F06}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {435E1011-E9FE-4E61-8B6D-2627DC6D1F06}.Release|Any CPU.Build.0 = Release|Any CPU
{435E1011-E9FE-4E61-8B6D-2627DC6D1F06}.Release|ARM.ActiveCfg = Release|Any CPU
{435E1011-E9FE-4E61-8B6D-2627DC6D1F06}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{435E1011-E9FE-4E61-8B6D-2627DC6D1F06}.Release|Mixed Platforms.Build.0 = Release|Any CPU
@@ -646,4 +651,3 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
-
View
2 ReactiveUI/BindingTypeConverters.cs
@@ -62,7 +62,7 @@ public static object DoReferenceCast<T>(object from)
var backingNullableType = Nullable.GetUnderlyingType(targetType);
if (backingNullableType == null) {
- return (T) Convert.ChangeType(from, targetType, null);
+ return (T) from;
}
if (from == null) {
View
7 ReactiveUI/MessageBus.cs
@@ -134,10 +134,9 @@ ISubject<T> SetupSubjectIfNecessary<T>(string contract)
}
void WithMessageBus(
- Type type,
- string contract,
- Action<Dictionary<Tuple<Type, string>, NotAWeakReference>,
- Tuple<Type, string>> block)
+ Type type, string contract,
+ Action<Dictionary<Tuple<Type, string>, NotAWeakReference>,
+ Tuple<Type, string>> block)
{
lock (messageBus) {
var tuple = new Tuple<Type, String>(type, contract);
View
2 ReactiveUI/Properties/AssemblyInfo.cs
@@ -4,7 +4,7 @@
[assembly: AssemblyDescription("An MVVM framework that integrates the Reactive Extensions")]
[assembly: AssemblyProduct("ReactiveUI")]
-[assembly: AssemblyVersion("4.1.0")]
+[assembly: AssemblyVersion("4.2.1")]
[assembly: InternalsVisibleTo("ReactiveUI.Explorables")]
[assembly: InternalsVisibleTo("ReactiveUI.Xaml")]
View
8 ReactiveUI/ReactiveUI.csproj
@@ -147,6 +147,9 @@
<Compile Include="MakeObjectReactiveHelper.cs" />
<Compile Include="RefcountDisposeWrapper.cs" />
<Compile Include="Reflection.cs" />
+ <Compile Include="Rx-Shim\AwaitableAsyncSubject.cs" />
+ <Compile Include="Rx-Shim\GetAwaiter.cs" />
+ <Compile Include="Rx-Shim\ImmutableList.cs" />
<Compile Include="RxApp.cs" />
<Compile Include="ScheduledSubject.cs" />
<Compile Include="Validation.cs" />
@@ -168,6 +171,9 @@
<ItemGroup>
<WCFMetadata Include="Service References\" />
</ItemGroup>
+ <ItemGroup>
+ <None Include="Rx-Shim\LICENSE" />
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
@@ -176,4 +182,4 @@
<Target Name="AfterBuild">
</Target>
-->
-</Project>
+</Project>
View
4 ReactiveUI/ReactiveUI_SL5.csproj
@@ -123,6 +123,9 @@
<Compile Include="ReactiveObject.cs" />
<Compile Include="RefcountDisposeWrapper.cs" />
<Compile Include="Reflection.cs" />
+ <Compile Include="Rx-Shim\AwaitableAsyncSubject.cs" />
+ <Compile Include="Rx-Shim\GetAwaiter.cs" />
+ <Compile Include="Rx-Shim\ImmutableList.cs" />
<Compile Include="RxApp.cs" />
<Compile Include="ScheduledSubject.cs" />
<Compile Include="ThreadLocal.cs" />
@@ -134,6 +137,7 @@
</Compile>
</ItemGroup>
<ItemGroup>
+ <None Include="Rx-Shim\LICENSE" />
<None Include="VariadicTemplates.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>VariadicTemplates.cs</LastGenOutput>
View
4 ReactiveUI/ReactiveUI_WP7.csproj
@@ -133,6 +133,9 @@
<Compile Include="ReactiveObject.cs" />
<Compile Include="RefcountDisposeWrapper.cs" />
<Compile Include="Reflection.cs" />
+ <Compile Include="Rx-Shim\AwaitableAsyncSubject.cs" />
+ <Compile Include="Rx-Shim\GetAwaiter.cs" />
+ <Compile Include="Rx-Shim\ImmutableList.cs" />
<Compile Include="RxApp.cs" />
<Compile Include="ScheduledSubject.cs" />
<Compile Include="ThreadLocal.cs" />
@@ -150,6 +153,7 @@
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
</ItemGroup>
<ItemGroup>
+ <None Include="Rx-Shim\LICENSE" />
<None Include="VariadicTemplates_WP7.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>VariadicTemplates_WP7.cs</LastGenOutput>
View
4 ReactiveUI/ReactiveUI_WP8.csproj
@@ -125,6 +125,9 @@
<Compile Include="ReactiveObject.cs" />
<Compile Include="RefcountDisposeWrapper.cs" />
<Compile Include="Reflection.cs" />
+ <Compile Include="Rx-Shim\AwaitableAsyncSubject.cs" />
+ <Compile Include="Rx-Shim\GetAwaiter.cs" />
+ <Compile Include="Rx-Shim\ImmutableList.cs" />
<Compile Include="RxApp.cs" />
<Compile Include="ScheduledSubject.cs" />
<Compile Include="ThreadLocal.cs" />
@@ -141,6 +144,7 @@
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
</ItemGroup>
<ItemGroup>
+ <None Include="Rx-Shim\LICENSE" />
<None Include="VariadicTemplates_WP7.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>VariadicTemplates_WP7.cs</LastGenOutput>
View
7 ReactiveUI/ReactiveUI_WinRT.csproj
@@ -14,6 +14,8 @@
<DefaultLanguage>en-US</DefaultLanguage>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{BC8A1FFA-BEE3-4634-8014-F334798102B3};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
+ <RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -68,6 +70,7 @@
</Compile>
</ItemGroup>
<ItemGroup>
+ <None Include="packages.config" />
<None Include="VariadicTemplates.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>VariadicTemplates.cs</LastGenOutput>
@@ -100,11 +103,13 @@
<VisualStudioVersion>11.0</VisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
+ <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
+ <Import Project="..\packages\Microsoft.Bcl.1.0.11-beta\tools\portable-net40+sl4+win8+wp71\Microsoft.Bcl.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
-</Project>
+</Project>
View
342 ReactiveUI/Rx-Shim/AwaitableAsyncSubject.cs
@@ -0,0 +1,342 @@
+#define HAS_AWAIT
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reactive.Disposables;
+using System.Reactive.Subjects;
+using System.Runtime.CompilerServices;
+using System.Text;
+using System.Threading;
+
+// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
+
+/* This file is substantially copied from http://rx.codeplex.com/SourceControl/changeset/view/ef6a42709f49#Rx.NET/System.Reactive.Linq/Reactive/Subjects/AsyncSubject.cs
+ * Check LICENSE in this folder for licensing information */
+
+namespace ReactiveUI
+{
+ /// <summary>
+ /// Represents the result of an asynchronous operation.
+ /// The last value before the OnCompleted notification, or the error received through OnError, is sent to all subscribed observers.
+ /// </summary>
+ /// <typeparam name="T">The type of the elements processed by the subject.</typeparam>
+ public sealed class AwaitableAsyncSubject<T> : ISubject<T>, IDisposable , INotifyCompletion
+ {
+ private readonly object _gate = new object();
+
+ private ImmutableList<IObserver<T>> _observers;
+ private bool _isDisposed;
+ private bool _isStopped;
+ private T _value;
+ private bool _hasValue;
+ private Exception _exception;
+
+ /// <summary>
+ /// Creates a subject that can only receive one value and that value is cached for all future observations.
+ /// </summary>
+ public AwaitableAsyncSubject()
+ {
+ _observers = new ImmutableList<IObserver<T>>();
+ }
+
+ /// <summary>
+ /// Notifies all subscribed observers about the end of the sequence, also causing the last received value to be sent out (if any).
+ /// </summary>
+ public void OnCompleted()
+ {
+ var os = default(IObserver<T>[]);
+
+ var v = default(T);
+ var hv = false;
+ lock (_gate)
+ {
+ CheckDisposed();
+
+ if (!_isStopped)
+ {
+ os = _observers.Data;
+ _observers = new ImmutableList<IObserver<T>>();
+ _isStopped = true;
+ v = _value;
+ hv = _hasValue;
+ }
+ }
+
+ if (os != null)
+ {
+ if (hv)
+ {
+ foreach (var o in os)
+ {
+ o.OnNext(v);
+ o.OnCompleted();
+ }
+ }
+ else
+ foreach (var o in os)
+ o.OnCompleted();
+ }
+ }
+
+ /// <summary>
+ /// Notifies all subscribed observers about the exception.
+ /// </summary>
+ /// <param name="error">The exception to send to all observers.</param>
+ /// <exception cref="ArgumentNullException"><paramref name="error"/> is null.</exception>
+ public void OnError(Exception error)
+ {
+ if (error == null)
+ throw new ArgumentNullException("error");
+
+ var os = default(IObserver<T>[]);
+ lock (_gate)
+ {
+ CheckDisposed();
+
+ if (!_isStopped)
+ {
+ os = _observers.Data;
+ _observers = new ImmutableList<IObserver<T>>();
+ _isStopped = true;
+ _exception = error;
+ }
+ }
+
+ if (os != null)
+ foreach (var o in os)
+ o.OnError(error);
+ }
+
+ /// <summary>
+ /// Sends a value to the subject. The last value received before successful termination will be sent to all subscribed and future observers.
+ /// </summary>
+ /// <param name="value">The value to store in the subject.</param>
+ public void OnNext(T value)
+ {
+ lock (_gate)
+ {
+ CheckDisposed();
+
+ if (!_isStopped)
+ {
+ _value = value;
+ _hasValue = true;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Subscribes an observer to the subject.
+ /// </summary>
+ /// <param name="observer">Observer to subscribe to the subject.</param>
+ /// <returns>Disposable object that can be used to unsubscribe the observer from the subject.</returns>
+ /// <exception cref="ArgumentNullException"><paramref name="observer"/> is null.</exception>
+ public IDisposable Subscribe(IObserver<T> observer)
+ {
+ if (observer == null)
+ throw new ArgumentNullException("observer");
+
+ var ex = default(Exception);
+ var v = default(T);
+ var hv = false;
+
+ lock (_gate)
+ {
+ CheckDisposed();
+
+ if (!_isStopped)
+ {
+ _observers = _observers.Add(observer);
+ return new Subscription(this, observer);
+ }
+
+ ex = _exception;
+ hv = _hasValue;
+ v = _value;
+ }
+
+ if (ex != null)
+ observer.OnError(ex);
+ else if (hv)
+ {
+ observer.OnNext(v);
+ observer.OnCompleted();
+ }
+ else
+ observer.OnCompleted();
+
+ return Disposable.Empty;
+ }
+
+ class Subscription : IDisposable
+ {
+ private readonly AwaitableAsyncSubject<T> _subject;
+ private IObserver<T> _observer;
+
+ public Subscription(AwaitableAsyncSubject<T> subject, IObserver<T> observer)
+ {
+ _subject = subject;
+ _observer = observer;
+ }
+
+ public void Dispose()
+ {
+ if (_observer != null)
+ {
+ lock (_subject._gate)
+ {
+ if (!_subject._isDisposed && _observer != null)
+ {
+ _subject._observers = _subject._observers.Remove(_observer);
+ _observer = null;
+ }
+ }
+ }
+ }
+ }
+
+ void CheckDisposed()
+ {
+ if (_isDisposed)
+ throw new ObjectDisposedException(string.Empty);
+ }
+
+ /// <summary>
+ /// Unsubscribe all observers and release resources.
+ /// </summary>
+ public void Dispose()
+ {
+ lock (_gate)
+ {
+ _isDisposed = true;
+ _observers = null;
+ _exception = null;
+ _value = default(T);
+ }
+ }
+
+#if HAS_AWAIT
+ /// <summary>
+ /// Gets an awaitable object for the current AsyncSubject.
+ /// </summary>
+ /// <returns>Object that can be awaited.</returns>
+ public AwaitableAsyncSubject<T> GetAwaiter()
+ {
+ return this;
+ }
+
+ /// <summary>
+ /// Specifies a callback action that will be invoked when the subject completes.
+ /// </summary>
+ /// <param name="continuation">Callback action that will be invoked when the subject completes.</param>
+ /// <exception cref="ArgumentNullException"><paramref name="continuation"/> is null.</exception>
+ public void OnCompleted(Action continuation)
+ {
+ if (continuation == null)
+ throw new ArgumentNullException("continuation");
+
+ OnCompleted(continuation, true);
+ }
+#endif
+
+ private void OnCompleted(Action continuation, bool originalContext)
+ {
+ //
+ // [OK] Use of unsafe Subscribe: this type's Subscribe implementation is safe.
+ //
+ this.Subscribe/*Unsafe*/(new AwaitObserver(continuation, originalContext));
+ }
+
+ class AwaitObserver : IObserver<T>
+ {
+#if HAS_AWAIT
+ private readonly SynchronizationContext _context;
+#endif
+ private readonly Action _callback;
+
+ public AwaitObserver(Action callback, bool originalContext)
+ {
+#if HAS_AWAIT
+ if (originalContext)
+ _context = SynchronizationContext.Current;
+#else
+ System.Diagnostics.Debug.Assert(!originalContext);
+#endif
+
+ _callback = callback;
+ }
+
+ public void OnCompleted()
+ {
+ InvokeOnOriginalContext();
+ }
+
+ public void OnError(Exception error)
+ {
+ InvokeOnOriginalContext();
+ }
+
+ public void OnNext(T value)
+ {
+ }
+
+ private void InvokeOnOriginalContext()
+ {
+#if HAS_AWAIT
+ if (_context != null)
+ {
+ //
+ // No need for OperationStarted and OperationCompleted calls here;
+ // this code is invoked through await support and will have a way
+ // to observe its start/complete behavior, either through returned
+ // Task objects or the async method builder's interaction with the
+ // SynchronizationContext object.
+ //
+ _context.Post(c => ((Action)c)(), _callback);
+ }
+ else
+#endif
+ {
+ _callback();
+ }
+ }
+ }
+
+ /// <summary>
+ /// Gets whether the AsyncSubject has completed.
+ /// </summary>
+ public bool IsCompleted
+ {
+ get
+ {
+ return _isStopped;
+ }
+ }
+
+ /// <summary>
+ /// Gets the last element of the subject, potentially blocking until the subject completes successfully or exceptionally.
+ /// </summary>
+ /// <returns>The last element of the subject. Throws an InvalidOperationException if no element was received.</returns>
+ /// <exception cref="InvalidOperationException">The source sequence is empty.</exception>
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "Await pattern for C# and VB compilers.")]
+ public T GetResult()
+ {
+ if (!_isStopped)
+ {
+ var e = new ManualResetEvent(false);
+ OnCompleted(() => e.Set(), false);
+ e.WaitOne();
+ }
+
+ if (_exception != null) {
+ throw _exception;
+ }
+
+ if (!_hasValue)
+ throw new InvalidOperationException("Sequence has no elements");
+
+ return _value;
+ }
+ }
+}
View
69 ReactiveUI/Rx-Shim/GetAwaiter.cs
@@ -0,0 +1,69 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reactive.Disposables;
+using System.Reactive.Subjects;
+using System.Text;
+using System.Threading;
+
+// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
+
+/* This file is substantially copied from http://rx.codeplex.com/SourceControl/changeset/view/ef6a42709f49#Rx.NET/System.Reactive.Linq/Reactive/Linq/QueryLanguage.Awaiter.cs
+ * Check LICENSE in this folder for licensing information */
+
+namespace ReactiveUI
+{
+ public static class ObservableAwaiter
+ {
+ public static AwaitableAsyncSubject<TSource> GetAwaiter<TSource>(this IObservable<TSource> source)
+ {
+ var s = new AwaitableAsyncSubject<TSource>();
+ source.SubscribeSafe(s);
+ return s;
+ }
+
+ public static AwaitableAsyncSubject<TSource> GetAwaiter<TSource>(this IConnectableObservable<TSource> source)
+ {
+ var s = new AwaitableAsyncSubject<TSource>();
+ source.SubscribeSafe(s);
+ source.Connect();
+ return s;
+ }
+
+ public static AwaitableAsyncSubject<TSource> RunAsync<TSource>(this IObservable<TSource> source, CancellationToken cancellationToken)
+ {
+ var s = new AwaitableAsyncSubject<TSource>();
+
+ var cancel = new Action(() => s.OnError(new OperationCanceledException()));
+ if (cancellationToken.IsCancellationRequested)
+ {
+ cancel();
+ return s;
+ }
+
+ var d = source.SubscribeSafe(s);
+ cancellationToken.Register(d.Dispose);
+ cancellationToken.Register(cancel);
+
+ return s;
+ }
+
+ public static AwaitableAsyncSubject<TSource> RunAsync<TSource>(this IConnectableObservable<TSource> source, CancellationToken cancellationToken)
+ {
+ var s = new AwaitableAsyncSubject<TSource>();
+
+ var cancel = new Action(() => s.OnError(new OperationCanceledException()));
+ if (cancellationToken.IsCancellationRequested)
+ {
+ cancel();
+ return s;
+ }
+
+ var d = new CompositeDisposable(source.SubscribeSafe(s), source.Connect());
+ cancellationToken.Register(d.Dispose);
+ cancellationToken.Register(cancel);
+
+ return s;
+ }
+ }
+}
View
60 ReactiveUI/Rx-Shim/ImmutableList.cs
@@ -0,0 +1,60 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
+
+/* This file is substantially copied from http://rx.codeplex.com/SourceControl/changeset/view/ef6a42709f49#Rx.NET/System.Reactive.Core/Reactive/Internal/ImmutableList.cs
+ * Check LICENSE in this folder for licensing information */
+
+namespace ReactiveUI
+{
+ internal class ImmutableList<T>
+ {
+ T[] data;
+
+ public ImmutableList()
+ {
+ data = new T[0];
+ }
+
+ public ImmutableList(T[] data)
+ {
+ this.data = data;
+ }
+
+ public ImmutableList<T> Add(T value)
+ {
+ var newData = new T[data.Length + 1];
+ Array.Copy(data, newData, data.Length);
+ newData[data.Length] = value;
+ return new ImmutableList<T>(newData);
+ }
+
+ public ImmutableList<T> Remove(T value)
+ {
+ var i = IndexOf(value);
+ if (i < 0)
+ return this;
+ var newData = new T[data.Length - 1];
+ Array.Copy(data, 0, newData, 0, i);
+ Array.Copy(data, i + 1, newData, i, data.Length - i - 1);
+ return new ImmutableList<T>(newData);
+ }
+
+ public int IndexOf(T value)
+ {
+ for (var i = 0; i < data.Length; ++i)
+ if (data[i].Equals(value))
+ return i;
+ return -1;
+ }
+
+ public T[] Data
+ {
+ get { return data; }
+ }
+ }
+}
+
View
15 ReactiveUI/Rx-Shim/LICENSE
@@ -0,0 +1,15 @@
+Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
+Microsoft Open Technologies would like to thank its contributors, a list
+of whom are at http://rx.codeplex.com/wikipage?title=Contributors.
+
+Licensed under the Apache License, Version 2.0 (the "License"); you
+may not use this file except in compliance with the License. You may
+obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+implied. See the License for the specific language governing permissions
+and limitations under the License.
View
13 ReactiveUI/RxApp.cs
@@ -9,6 +9,7 @@
using System.Linq.Expressions;
using System.Reactive.Subjects;
using System.Reflection;
+using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
@@ -421,15 +422,16 @@ static IEnumerable<string> attemptToEarlyLoadReactiveUIDLLs()
return new[] {"ReactiveUI.Xaml"};
#else
var name = Assembly.GetExecutingAssembly().GetName();
+ var suffix = getArchSuffixForPath(Assembly.GetExecutingAssembly().Location);
return guiLibs.SelectMany(x => {
- var fullName = String.Format("{0}, Version={1}, Culture=neutral, PublicKeyToken=null", x, name.Version.ToString());
+ var fullName = String.Format("{0}{1}, Version={2}, Culture=neutral, PublicKeyToken=null", x, suffix, name.Version.ToString());
var assemblyLocation = Assembly.GetExecutingAssembly().Location;
if (String.IsNullOrEmpty(assemblyLocation))
return Enumerable.Empty<string>();
- var path = Path.Combine(Path.GetDirectoryName(assemblyLocation), x + ".dll");
+ var path = Path.Combine(Path.GetDirectoryName(assemblyLocation), x + suffix + ".dll");
if (!File.Exists(path) && !RxApp.InUnitTestRunner()) {
LogHost.Default.Debug("Couldn't find {0}", path);
return Enumerable.Empty<string>();
@@ -445,6 +447,13 @@ static IEnumerable<string> attemptToEarlyLoadReactiveUIDLLs()
});
#endif
}
+
+ static string getArchSuffixForPath(string path)
+ {
+ var re = new Regex(@"(_[A-Za-z0-9]+)\.");
+ var m = re.Match(Path.GetFileName(path));
+ return m.Success ? m.Groups[1].Value : "";
+ }
}
public class NullDefaultPropertyBindingProvider : IDefaultPropertyBindingProvider
View
5 ReactiveUI/packages.config
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="Microsoft.Bcl" version="1.0.11-beta" targetFramework="win" />
+ <package id="Microsoft.Bcl.Async" version="1.0.12-beta" targetFramework="win" />
+</packages>
View
4 packages/repositories.config
@@ -2,9 +2,9 @@
<repositories>
<repository path="..\PerfConsoleRunner\packages.config" />
<repository path="..\ReactiveUI.NLog\packages.config" />
- <repository path="..\ReactiveUI.Sample\ReactiveUI.Sample.Tests\packages.config" />
- <repository path="..\ReactiveUI.Sample\ReactiveUI.Sample\packages.config" />
<repository path="..\ReactiveUI.Serialization.Esent\packages.config" />
<repository path="..\ReactiveUI.Serialization.Tests\packages.config" />
<repository path="..\ReactiveUI.Serialization\packages.config" />
+ <repository path="..\ReactiveUI.Tests\packages.config" />
+ <repository path="..\ReactiveUI\packages.config" />
</repositories>

0 comments on commit 184f6f0

Please sign in to comment.