Example #1
0
        public async Task SaveWeatherInfoAsync(BasicWeatherInfo info)
        {
            string json = _utils.SerializeToJson(info);
            await File.AppendAllTextAsync(_filePath, Environment.NewLine);

            await File.AppendAllTextAsync(_filePath, $"{DateTime.Now}-----{json}");
        }
Example #2
0
 public void ShowWeatherInfo(BasicWeatherInfo info)
 {
     Console.WriteLine(new string('-', 50));
     Console.WriteLine($"Service: {info.ServiceName}");
     Console.WriteLine($"Temp: {info.Temperature}, Wind: {info.Wind}, Clouds: {info.Clouds}");
     Console.WriteLine(new string('-', 50));
 }
Example #3
0
        static async Task Main(string[] args)
        {
            IWeatherInfoManager manager = WeatherInfoServiceFactory.GetWeatherInfoManager();
            BasicWeatherInfo    info    = await manager.GetWeatherInfoAsync("Kiev");

            manager.ShowWeatherInfo(info);
            await manager.SaveWeatherInfoAsync(info);

            Console.ReadKey();
        }
Example #4
0
        public virtual async Task <BasicWeatherInfo> GetWeatherInfoAsync(string city)
        {
            List <Task <BasicWeatherInfo> >   tasks    = new List <Task <BasicWeatherInfo> >();
            IEnumerable <IWeatherInfoService> services = WeatherInfoServiceFactory.GetWeatherServices();

            services.ForEach(service => tasks.Add(service.GetWeatherInfoAsync(city)));
            BasicWeatherInfo result = await tasks.GetFirstSuccessfulTask();

            return(result);
        }
Example #5
0
 public virtual void ShowWeatherInfo(BasicWeatherInfo info)
 {
     _viewManager.ShowWeatherInfo(info);
 }
Example #6
0
 public virtual async Task SaveWeatherInfoAsync(BasicWeatherInfo info)
 {
     await _repository.SaveWeatherInfoAsync(info);
 }