示例#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
         }));
     }
 }
示例#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());
        }