Beispiel #1
0
 public static void Save(ViewConfiguration viewConfiguration)
 {
     using (var streamWriter = new StreamWriter(ViewConfigPath))
     {
         streamWriter.Write(JsonConvert.SerializeObject(viewConfiguration, Formatting.Indented,
                                                        new JsonSerializerSettings()
         {
             NullValueHandling = NullValueHandling.Ignore
         }));
     }
 }
Beispiel #2
0
        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());
        }