GeoLocationViewModel.Start method instantiates either the
GeolocatorProxy or a
MockGeoLocator depending on the value of the viewmodel’s Boolean
useMockLocator field (see Listing 17.6).
Rather than requiring the viewmodel to determine which
IGeoLocator implementation it should use, Inversion of Control (IoC) could be employed to resolve the object. IoC is discussed in Chapter 24, “Unit Testing Apps.”
Start method subscribes to the
StatusChanged events of the
IGeoLocator, and then calls the
Start method to begin receiving location notifications.
PositionChanged event is raised, the viewmodel’s
GeoCoordinate property is set to the current location.