public static void Save(ViewConfiguration viewConfiguration) { using (var streamWriter = new StreamWriter(ViewConfigPath)) { streamWriter.Write(JsonConvert.SerializeObject(viewConfiguration, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore })); } }
public static ViewConfiguration RestoreViewConfiguration() { ViewConfiguration viewConfiguration; try { using (var streamReader = new StreamReader(ViewConfigPath)) { viewConfiguration = JsonConvert.DeserializeObject <ViewConfiguration>(streamReader.ReadToEnd()); } } catch (Exception) { viewConfiguration = null; } return(viewConfiguration ?? ViewConfiguration.Default()); }