Skip to content
This repository
Browse code

Add methods to override Geolocation

  • Loading branch information...
commit f92a87ac8e4d464cd17b17c543258a391c11f592 1 parent baaa1af
Paul Betts authored December 08, 2012

Showing 1 changed file with 18 additions and 6 deletions. Show diff stats Hide diff stats

  1. 24  ReactiveUI.Mobile/Geolocation.cs
24  ReactiveUI.Mobile/Geolocation.cs
@@ -93,16 +93,18 @@ public static IObservable<Position> GetPosition(bool includeHeading = false)
93 93
             ret.Connect();
94 94
             return ret;
95 95
         }
96  
-    }
97 96
 
98  
-    public class GeolocationException : Exception
99  
-    {
100  
-        public GeolocationException(GeolocationError error)
  97
+        public static IDisposable WithGeolocator(IReactiveGeolocator implementation)
101 98
         {
102  
-            Info = error;
  99
+            var orig = Implementation;
  100
+            Implementation = implementation;
  101
+            return Disposable.Create(() => Implementation = orig);
103 102
         }
104 103
 
105  
-        public GeolocationError Info { get; protected set; }
  104
+        public static IDisposable UseLocationData(IObservable<Position> positionStream, IScheduler scheduler = null)
  105
+        {
  106
+            return WithGeolocator(new TestGeolocator(positionStream, scheduler));
  107
+        }
106 108
     }
107 109
 
108 110
     public class TestGeolocator : IReactiveGeolocator
@@ -151,4 +153,14 @@ public IObservable<Position> GetPosition(bool includeHeading = false)
151 153
                 Math.Pow(rhs.Longitude - lhs.Longitude, 2.0));
152 154
         }
153 155
     }
  156
+
  157
+    public class GeolocationException : Exception
  158
+    {
  159
+        public GeolocationException(GeolocationError error)
  160
+        {
  161
+            Info = error;
  162
+        }
  163
+
  164
+        public GeolocationError Info { get; protected set; }
  165
+    }
154 166
 }

0 notes on commit f92a87a

Please sign in to comment.
Something went wrong with that request. Please try again.