/// <summary> /// Returns a list of projections. /// </summary> /// <returns></returns> public List <Projections> ReadFromProjectionFile() { try { using (var r = new StreamReader(applicationService.GetProjectionFilePath())) { var json = r.ReadToEnd(); var selecedFiles = JsonConvert.DeserializeObject <List <Projections> >(json); r.Close(); return(selecedFiles); } } catch (Exception) { return(new List <Projections>()); } }
/// <summary> /// Write list of projections to file in case epsg-registry won't respond /// </summary> /// <param name="projections"></param> public void WriteToProjectionFile(List <Projections> projections) { var serializer = new JsonSerializer(); serializer.Converters.Add(new JavaScriptDateTimeConverter()); serializer.NullValueHandling = NullValueHandling.Ignore; try { using (var outputFile = new StreamWriter(ApplicationService.GetProjectionFilePath(), false)) using (JsonWriter writer = new JsonTextWriter(outputFile)) { serializer.Serialize(writer, projections); Log.Debug("Write to projection file"); writer.Close(); } } catch (Exception e) { Log.Error(e, "Write to projection file"); } }