Permalink
Browse files

Work around weird assembly mismatches

  • Loading branch information...
1 parent 51c136f commit a45231179f33f982fdea4163c779b515e963818c @paulcbetts paulcbetts committed Dec 16, 2012
Showing with 18 additions and 0 deletions.
  1. +18 −0 ReactiveUI.Mobile/Geolocation.cs
@@ -76,6 +76,7 @@ public static IObservable<Position> GetPosition(bool includeHeading = false)
return Implementation.GetPosition(includeHeading);
}
+#if !WP7 && !WP8
var ret = Observable.Create<Position>(subj => {
var geo = new Geolocator();
var cts = new CancellationTokenSource();
@@ -89,6 +90,23 @@ public static IObservable<Position> GetPosition(bool includeHeading = false)
disp.Add(geo.GetPositionAsync(cts.Token, includeHeading).ToObservable().Subscribe(subj));
return disp;
}).Multicast(new AsyncSubject<Position>());
+#else
+ // NB: Xamarin.Mobile.dll references CancellationTokenSource, but
+ // the one we have comes from the BCL Async library - if we try to
+ // pass in our type into the Xamarin library, it gets confused.
+ var ret = Observable.Create<Position>(subj => {
+ var geo = new Geolocator();
+ var disp = new CompositeDisposable();
+
+ if (!geo.IsGeolocationAvailable || !geo.IsGeolocationEnabled) {
+ return Observable.Throw<Position>(new Exception("Geolocation isn't available")).Subscribe(subj);
+ }
+
+ disp.Add(geo.GetPositionAsync(Int32.MaxValue, includeHeading).ToObservable().Subscribe(subj));
+ return disp;
+ }).Multicast(new AsyncSubject<Position>());
+#endif
+
return ret.RefCount();
}

0 comments on commit a452311

Please sign in to comment.