public IEnumerable <Rates> GetRates() { _myTracing.Debug(string.Format("{0} --- {1}", nameof(DataManager), nameof(GetRates))); string endpoint = ConfigurationManager.AppSettings["RatesUrl"]; if (string.IsNullOrEmpty(endpoint)) { _myTracing.Error(string.Format("Rates Url could not be found in config")); throw new NullReferenceException(); } string json = _jsonProvider.GetDataFromUri(endpoint); try { RatesList = new List <Rates>(); RatesList = JsonConvert.DeserializeObject <List <Rates> >(json); } catch (Exception ex) { _myTracing.Error(string.Format("Error when DeserializeObject was invoke : {0}", ex.Message)); throw ex; } Task.Run(() => _fileProvider.Write(RatesList)); return(RatesList); }
public void Write(object instance) { try { _myTracing.Debug(string.Format("{0} --- {1}", nameof(PersistentManager), nameof(Write))); string directoryPath = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); if (instance is IEnumerable <Rates> rateList) { using (StreamWriter file = File.CreateText(directoryPath + @"/rates.json")) { JsonSerializer serializer = new JsonSerializer(); serializer.Serialize(file, rateList); } } else if (instance is IEnumerable <Transaction> transactionList) { using (StreamWriter file = File.CreateText(directoryPath + @"/transactions.json")) { JsonSerializer serializer = new JsonSerializer(); serializer.Serialize(file, transactionList); } } } catch (Exception ex) { _myTracing.Error(string.Format("Error when the data had been saving in disk : {0}", ex.Message)); } }
public string InstallPackages( string projectContent, Dictionary <string, NuGetPackage> requestedPackages, Dictionary <string, NuGetPackage> installedPackages, string projectName, ITracing tracing) { tracing.Debug($"Skipped processing project '{projectName}' as its type is unsupported."); return(projectContent); }
public void Debug(string message) => _tracing.Debug($"{_prefix}{message}");