Last active
December 31, 2015 18:49
-
-
Save teo-mateo/8029946 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class LocationSubscriber : IObserver<Location> | |
| { | |
| private IDisposable unsubscriber; | |
| private string instName; | |
| public LocationSubscriber(string name) | |
| { | |
| this.instName = name; | |
| } | |
| public string Name { get { return this.instName; } } | |
| public virtual void Subscribe(IObservable<Location> provider) | |
| { | |
| if (provider != null) | |
| unsubscriber = provider.Subscribe(this); | |
| } | |
| public virtual void OnCompleted() | |
| { | |
| Console.WriteLine("The Location Tracker has completed transmitting datat to {0}", this.Name); | |
| this.Unsubscribe(); | |
| } | |
| public virtual void OnError(Exception ex) | |
| { | |
| Console.WriteLine("{0} location cannot be determined.", this.Name); | |
| } | |
| public virtual void OnNext(Location value) | |
| { | |
| Console.WriteLine("{2}: the current location is {0}, {1}", value.Latitude, value.Longitude, this.Name); | |
| } | |
| public virtual void Unsubscribe() | |
| { | |
| unsubscriber.Dispose(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment