Exemple #1
0
        public void SaveSettings(PMSettingsModel settings)
        {
            if (settings == null)
            {
                return;
            }

            using (rwlock.Write())
            {
                settingsModel = settings.Clone();

                try
                {
                    var serializer = new DataContractSerializer(typeof(PMSettingsModel));

                    using (var fs = File.Open(settingsFileName, FileMode.Create))
                    {
                        using (var writer = new XmlTextWriter(fs, Encoding.UTF8))
                        {
                            writer.Formatting = Formatting.Indented;
                            serializer.WriteObject(writer, settingsModel);
                        }
                    }
                }
                catch (Exception e)
                {
                    LogProvider.Log.Error(this, e);
                }
            }
        }
Exemple #2
0
 public PMSettingsModel GetSettings()
 {
     using (rwlock.Read())
     {
         return(settingsModel.Clone());
     }
 }