Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            WeatherDataServiceFactory serviceFactory = new WeatherDataServiceFactory();
            IWeatherDataService       newService     = serviceFactory.GetWeatherDataService(dataServices.OPEN_WEATHER_MAP);
            Location    location = new Location("Tel Aviv", "IL");
            WeatherData data     = newService.GetWeatherData(location);

            Console.WriteLine(data.ToString());
            Debug.WriteLine(data.ToString());

            Console.ReadLine();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The main core of the application which handels all the classes
        /// and eventually print the details wich the user chosen into the screen
        /// </summary>

        static void Main(string[] args)
        {
            string site = "OPEN_WEATHER_MAP";
            // using the site value within the WeatherDataServiceFactory which implemented by the Factory Design Pattern
            IWeatherDataService iw = WeatherDataServiceFactory.GetWeatherDataService(site);

            Console.WriteLine("For weather details, please Enter the name of the required city: \n");
            string      locCity = Console.ReadLine(); // location value from the user
            Location    locMain = new Location(locCity);
            WeatherData wd      = iw.GetWeatherData(locMain);

            wd.PrintDetails();
            Console.ReadKey();
        }
Ejemplo n.º 3
0
        public delegate void AnonymousPrint(ref IWeatherDataService service1);//Anonymous Method

        public static void Main(string[] args)
        {
            try
            {
                IWeatherDataService Service            = WeatherDataServiceFactory.getWeatherDataService(WeatherDataServiceFactory.OPEN_WEATHER_MAP);
                WeatherData         weatherData        = Service.getWeatherData(new Location("Haifa"));
                AnonymousPrint      DisplayServiceName = delegate(ref IWeatherDataService CurrentService)
                {
                    Console.WriteLine("Information Was Received From: " + CurrentService.ToString());
                };
                weatherData.PrintToScreen();
                DisplayServiceName(ref Service);
            }
            catch (WeatherDataException w)
            {
                Console.WriteLine(w.ToString());
            }
            finally
            {
                Console.ReadKey();
            }
        }