Skip to content

Commit 2cc1c40

Browse files
author
Paul Betts
committed
Merge pull request #459 from reactiveui/always-initialize-rxui
Always initialize ReactiveUI
2 parents c0cd47c + 5373ee3 commit 2cc1c40

15 files changed

+45
-2
lines changed

ReactiveUI.Platforms/Android/ActivityRoutedViewHost.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using Android.Widget;
1414
using ActionbarSherlock.App;
1515
using Splat;
16+
using ReactiveUI;
1617

1718
namespace ReactiveUI.Android
1819
{
@@ -23,6 +24,8 @@ public sealed class ActivityRoutedViewHost : IDisposable
2324

2425
public ActivityRoutedViewHost(Activity hostActivity, IViewLocator viewLocator = null)
2526
{
27+
RxApp.EnsureInitialized();
28+
2629
viewLocator = viewLocator ?? ViewLocator.Current;
2730
var platform = Locator.Current.GetService<IPlatformOperations>();
2831

ReactiveUI.Platforms/Cocoa/RoutedViewHost.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public NSViewController DefaultContent {
4747

4848
public RoutedViewHost(NSView targetView)
4949
{
50+
RxApp.EnsureInitialized();
5051
NSView viewLastAdded = null;
5152

5253
ViewContractObservable = Observable.Return(default(string));
@@ -82,4 +83,4 @@ public RoutedViewHost(NSView targetView)
8283
}, RxApp.DefaultExceptionHandler.OnNext);
8384
}
8485
}
85-
}
86+
}

ReactiveUI.Platforms/Cocoa/RouterUINavigationController.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using MonoTouch.Foundation;
1111
using System.ComponentModel;
1212
using Splat;
13+
using ReactiveUI;
1314

1415
namespace ReactiveUI.Cocoa
1516
{
@@ -20,6 +21,8 @@ public class RouterUINavigationController : UINavigationController
2021

2122
public RouterUINavigationController(IRoutingState router, IViewLocator viewLocator = null)
2223
{
24+
RxApp.EnsureInitialized();
25+
2326
this.router = router;
2427
viewLocator = viewLocator ?? ViewLocator.Current;
2528

ReactiveUI.Platforms/Cocoa/ViewModelViewHost.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Reactive;
33
using System.Reactive.Linq;
4+
using ReactiveUI;
45

56
#if UIKIT
67
using MonoTouch.UIKit;
@@ -26,6 +27,8 @@ public class ViewModelViewHost : ReactiveObject
2627
{
2728
public ViewModelViewHost(NSView targetView)
2829
{
30+
RxApp.EnsureInitialized();
31+
2932
NSView viewLastAdded = null;
3033

3134
ViewContractObservable = Observable.Return(default(string));

ReactiveUI.Platforms/Winforms/RoutedViewHost.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Reactive.Linq;
66
using System.Runtime.CompilerServices;
77
using System.Windows.Forms;
8+
using ReactiveUI;
89

910
namespace ReactiveUI.Winforms
1011
{
@@ -20,6 +21,7 @@ public partial class RoutedViewHost : UserControl, INotifyPropertyChanged, INoti
2021

2122
public RoutedViewHost()
2223
{
24+
RxApp.EnsureInitialized();
2325
this.InitializeComponent();
2426

2527
this.disposables.Add(this.WhenAny(x => x.DefaultContent, x => x.Value).Subscribe(x => {

ReactiveUI.Platforms/Winforms/ViewModelViewHost.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Reactive.Linq;
66
using System.Runtime.CompilerServices;
77
using System.Windows.Forms;
8+
using ReactiveUI;
89

910
namespace ReactiveUI.Winforms
1011
{
@@ -20,6 +21,7 @@ public partial class ViewModelViewHost : UserControl, INotifyPropertyChanged, IN
2021

2122
public ViewModelViewHost()
2223
{
24+
RxApp.EnsureInitialized();
2325
this.InitializeComponent();
2426

2527
this.disposables.Add(this.WhenAny(x => x.DefaultContent, x => x.Value).Subscribe(x => {

ReactiveUI.Platforms/Xaml/RoutedViewHost.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public IObservable<string> ViewContractObservable {
5959

6060
public RoutedViewHost()
6161
{
62+
RxApp.EnsureInitialized();
6263
HorizontalContentAlignment = HorizontalAlignment.Stretch;
6364
VerticalContentAlignment = VerticalAlignment.Stretch;
6465

ReactiveUI.Platforms/Xaml/ViewModelViewHost.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ public IObservable<string> ViewContractObservable {
5555

5656
public ViewModelViewHost()
5757
{
58+
RxApp.EnsureInitialized();
59+
5860
// NB: InUnitTestRunner also returns true in Design Mode
5961
if (ModeDetector.InUnitTestRunner()) {
6062
ViewContractObservable = Observable.Never<string>();

ReactiveUI/CommandBinding.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
using System.Text;
1010
using System.Windows.Input;
1111
using Splat;
12-
using Splat;
12+
using ReactiveUI;
1313

1414
namespace ReactiveUI
1515
{
@@ -19,6 +19,8 @@ public static class CommandBinder
1919

2020
static CommandBinder()
2121
{
22+
RxApp.EnsureInitialized();
23+
2224
binderImplementation = Locator.Current.GetService<ICommandBinderImplementation>() ??
2325
new CommandBinderImplementation();
2426
}

ReactiveUI/DefaultPropertyBinding.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ public class DefaultPropertyBinding
1010
{
1111
public static string GetPropertyForControl(object control)
1212
{
13+
RxApp.EnsureInitialized();
14+
1315
return Locator.Current.GetServices<IDefaultPropertyBindingProvider>()
1416
.Select(x => x.GetPropertyForControl(control))
1517
.Where(x => x != null)

0 commit comments

Comments
 (0)