public StyleSettings Get()
 {
     StyleSettings styleSettings = null;
     if (!File.Exists(file))
     {
         styleSettings = new StyleSettings
                        {
                           Settings = new List<StyleSetting>{}
                        };
         Save(styleSettings);
         return styleSettings;
     }
     styleSettings = null;
     StreamReader sr = null;
     try
     {
         sr = new StreamReader(file);
         var str = sr.ReadToEnd();
         var serializer = new JavaScriptSerializer();
         styleSettings = serializer.Deserialize<StyleSettings>(str);
     }
     finally
     {
         sr.Close();
         sr.Dispose();
         sr = null;
     }
     return styleSettings;
 }
 public void Save(StyleSettings styleSettings)
 {
     StreamWriter sw = null;
     try
     {
         sw = new StreamWriter(file);
         var serializer = new JavaScriptSerializer();
         var str = serializer.Serialize(styleSettings);
         sw.Write(str);
         sw.Flush();
     }
     finally
     {
         sw.Close();
         sw.Dispose();
         sw = null;
     }
 }
Beispiel #3
0
 public void SetStyleSettings(StyleSettings settings)
 {
     _dal.StyleSettingsProvider.Save(settings);
 }