Example #1
0
        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();
        }
Example #3
0
        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();
        }
Example #4
0
    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();
    }
Example #5
0
        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();
        }