static async Task Main() { CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; locationProvider = new LocationTracker(); var min = new LocationDTO { Longitude = -10, Latitude = -10 }; var max = new LocationDTO { Longitude = 10, Latitude = 10 }; locationReporter = new LocationReporter(Mapper.Map(min), Mapper.Map(max)); locationReporter.Subscribe(locationProvider, Console.WriteLine, (x) => Console.WriteLine(x.Message), (x) => { }, TurnOffAll, TurnOnAll ); deviceProvider = new DeviceTracker(); deviceReporter = new DeviceReporter(); deviceReporter.Subscribe(deviceProvider, Console.WriteLine, (x) => Console.WriteLine(x.Message), (x) => { _ = CurrentConnection.SendAsync(MessageParser.CreateMessage("OnNext", x, x.GetType().Name)); } ); await CreateServer(); }
public static void Observer() { // custom var weatherData = new WeatherData(); var currentDisplay = new CurrentConditionDisplay(weatherData); weatherData.SetMeasurements(80, 65, 30.4f); weatherData.SetMeasurements(82, 70, 29.2f); // using buildin class var provider = new LocationTracker(); var reporter1 = new LocationReporter("Report1"); reporter1.Subscribe(provider); var reporter2 = new LocationReporter("Report2"); reporter2.Subscribe(provider); provider.TrackLocation(new Location(47.6456, -122.1312)); reporter1.Unsubscribe(); provider.TrackLocation(new Location(47.6677, -122.1199)); provider.TrackLocation(null); provider.EndTransmission(); }
public void TestMethod1() { // Define a provider and two observers. LocationTracker provider = new LocationTracker(); LocationReporter reporter1 = new LocationReporter("FixedGPS"); reporter1.Subscribe(provider); LocationReporter reporter2 = new LocationReporter("MobileGPS"); reporter2.Subscribe(provider); provider.TrackLocation(new Location(47.6456, -122.1312)); reporter1.Unsubscribe(); provider.TrackLocation(new Location(47.6677, -122.1199)); provider.TrackLocation(null); provider.EndTransmission(); }
static void Main(string[] args) { LocationTracker provider = new LocationTracker(); LocationReporter reporter1 = new LocationReporter("FixedGPS"); reporter1.Subscribe(provider); LocationReporter reporter2 = new LocationReporter("MobileGPS"); reporter2.Subscribe(provider); provider.TrackLocation(new Location(1, 2)); reporter1.Unsubscribe(); provider.TrackLocation(new Location(3, 4)); provider.TrackLocation(null); provider.EndTransmission(); }
static void Main(string[] args) { // Define a provider and two observers. LocationTracker provider = new LocationTracker(); LocationReporter reporter1 = new LocationReporter("FixedGPS"); reporter1.Subscribe(provider); LocationReporter reporter2 = new LocationReporter("MobileGPS"); reporter2.Subscribe(provider); provider.TrackLocation(new Location(47.6456, -122.1312)); reporter1.Unsubscribe(); provider.TrackLocation(new Location(47.6677, -122.1199)); provider.TrackLocation(null); provider.EndTransmission(); }
static void Main(string[] args) { //Define a provider and two observers LocationTracker provider = new LocationTracker(); LocationReporter reporter1 = new LocationReporter("FixGPS"); reporter1.Subscribe(provider); LocationReporter reporter2 = new LocationReporter("MobileGPS"); reporter2.Subscribe(provider); provider.TrackLocation(new Location(47.6456, -122.1312)); reporter1.Unsubscribe(); provider.TrackLocation(new Location(47.6677, -122.1199)); provider.TrackLocation(null); provider.EndTransmission(); Console.ReadKey(); }
private static void RecreatedReporterAndTrackerExample() { Console.WriteLine("02 Rebuild Observable with Rx"); var provider = new LocationTracker(); // Observable var reporter1 = new LocationReporter("FixedGPS "); // Observer reporter1.Subscribe(provider); var reporter2 = new LocationReporter("MobileGPS"); // Observer reporter2.Subscribe(provider); provider.TrackLocation(new Location(47.6456, -123.1312)); provider.TrackLocation(new Location(31.6677, -11.1199)); reporter1.OnCompleted(); provider.TrackLocation(new Location(84.6677, -21.1023)); provider.TrackLocation(null); provider.EndTransmission(); ConsoleUtils.WaitForEnter(); }