예제 #1
0
            private void SavePreferenceContainer(PreferenceContainer container)
            {
                if (!preferenceSetFile.Directory.Exists)
                {
                    preferenceSetFile.Directory.Create();
                }

                using (var writer = new StreamWriter(preferenceSetFile.Open(FileMode.Create, FileAccess.Write, FileShare.None)))
                {
                    XmlSerializer.Serialize(writer, container);
                }
            }
예제 #2
0
            public void Commit()
            {
                if (modified)
                {
                    PreferenceContainer container = new PreferenceContainer();
                    foreach (var pair in contents)
                    {
                        container.Settings.Add(new PreferenceSetting(pair.Key, pair.Value));
                    }

                    SavePreferenceContainer(container);

                    cachedTimestamp = GetTimestamp();
                    modified        = false;
                }
            }
예제 #3
0
 private void EnsureLoaded()
 {
     if (!cachedTimestamp.HasValue)
     {
         cachedTimestamp = GetTimestamp();
         if (cachedTimestamp.HasValue)
         {
             PreferenceContainer container = LoadPreferenceContainer();
             if (container != null)
             {
                 foreach (var setting in container.Settings)
                 {
                     contents[setting.Name] = setting.Value;
                 }
             }
         }
     }
 }