예제 #1
0
        public string Format(string data)
        {
            var rawWeather = JsonConvert.DeserializeObject <OpenWeatherPublicModel>(data);
            var json       = JsonConvert.SerializeObject(rawWeather);

            return(_format.Format(json));
        }
예제 #2
0
        /// <summary>
        /// The method used to format and push over a stream a given logging information.
        /// </summary>
        /// <param name="log">The given logging information to store.</param>
        public void Store(Log log)
        {
            var formattedLog = _format.Format(log);

            _writer.WriteLine(formattedLog);

            _writer.Flush();
        }
예제 #3
0
        public string Execute(string cityName, IFormat formatter)
        {
            var cityResult = _weatherCityRepository.GetOpenWeatherCityId(cityName);

            if (cityResult.IsFailure)
            {
                return(cityResult.Error);
            }

            var weatherInformationResult = _weatherCityService.GetCityWeatherInformation(cityResult.Value);

            return(weatherInformationResult.IsSuccess ? formatter.Format(weatherInformationResult.Value) : weatherInformationResult.Error);
        }
예제 #4
0
        public TItem GetAllData()
        {
            var cacheKey = "all_data";

            var cachedData = _cache.Get(cacheKey);

            if (cachedData == null)
            {
                var filePath      = _dataSource.GetDataSource();
                var fileContent   = File.ReadAllText(filePath);
                var formattedData = _formatter.Format(fileContent);

                _cache.Add(cacheKey, formattedData);

                return(formattedData);
            }

            return(cachedData);
        }
예제 #5
0
 public string GetSummary()
 {
     return(_format.Format(_flightService));
 }
예제 #6
0
 public override string ToString()
 {
     return(_formatter.Format(this));
 }
 /// <summary>
 /// The FormatData method is used to convert a file into a format that users want
 /// </summary>
 /// <param name="formatType"></param>
 /// <param name="file"></param>
 /// <param name="itemName"></param>
 /// <returns></returns>
 public FormatItem FormatData(IFormat formatType, BaseFile file, string itemName = "")
 {
     return(formatType.Format(file.GetValueList(), itemName));
 }