/// <summary> /// Private helper method for performing deletes on a setting /// </summary> /// <param name="store">The IsolatedStorageSettings store to use (either "site" or "application")</param> /// <param name="key">The key of the object to delete</param> private static void DeleteSetting(IsolatedStorageSettings store, string key) { if(store.Contains(key)) { store.Remove(key); store.Save(); } }
//constructor gets settings public StorageSetting() { settings = IsolatedStorageSettings.ApplicationSettings; if (!settings.Contains(RouteMode)) { settings.Add(RouteMode, RouteModeDefault); settings.Save(); } }
// コンストラクター public MainPage() { InitializeComponent(); // ListBox コントロールのデータ コンテキストをサンプル データに設定します DataContext = App.ViewModel; this.Loaded += new RoutedEventHandler(MainPage_Loaded); store = IsolatedStorageSettings.ApplicationSettings; #if DEBUG store.Clear(); store.Save(); #endif }
private void SaveCity(string city) { m_appSettings = IsolatedStorageSettings.ApplicationSettings; if (m_appSettings.Contains("city")) { m_appSettings["city"] = city; } else { m_appSettings.Add("city", city); } m_appSettings.Save(); WebService.City = city; }
public AppSettings(IsolatedStorageSettings settings) { if (settings == null) throw new ArgumentNullException("settings"); _settings = settings; _globalPass = new GlobalPassHandler(this); if (!_settings.Contains(KEY_INSTANCE_ID)) { _instanceId = Guid.NewGuid().ToString("N"); _settings[KEY_INSTANCE_ID] = _instanceId; _settings.Save(); } else _instanceId = (string)_settings[KEY_INSTANCE_ID]; }
public static void Write <TT>(string name, TT value) { System.IO.IsolatedStorage.IsolatedStorageSettings settings = System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings; if (settings == null) { return; } if (settings.Contains(name)) { settings[name] = value; } else { settings.Add(name, value); } settings.Save(); }
private void loadSettings() { settings = IsolatedStorageSettings.ApplicationSettings; if (!settings.Contains("cm")) { cm = true; settings.Add("cm", "1"); settings.Save(); } else { string cmSetting = IsolatedStorageSettings.ApplicationSettings["cm"] as string; if (cmSetting.Contains("1")) { cm = true; } else { cm = false; } } if (settings.Contains("login")) { btnLogout.IsEnabled = true; } }
/// <summary> /// Private helper method for performing saves on settings /// </summary> /// <param name="store">The IsolatedStorageSettings store to use (either "site" or "application")</param> /// <param name="key">The key of the object to save</param> /// <param name="value">The value to be saved in storage</param> private static void SaveOrUpdateSetting(IsolatedStorageSettings store, string key, object value) { if (store.Contains(key)) { store[key] = value; } //Otheriwse, add this new key and its value to the store else { store.Add(key, value); } store.Save(); }
public void Format (IsolatedStorageSettings settings, IsolatedStorageFile isf) { settings.Clear (); settings.Add ("a", 1); settings.Save (); Dictionary<string, object> dict = null; using (IsolatedStorageFileStream fs = new IsolatedStorageFileStream ("__LocalSettings", FileMode.Open, isf)) { using (StreamReader sr = new StreamReader (fs)) { DataContractSerializer reader = new DataContractSerializer (typeof (Dictionary<string, object>)); dict = (Dictionary<string, object>) reader.ReadObject (fs); } } Assert.AreEqual (1, dict.Count, "settings.Count"); Assert.AreEqual (1, dict ["a"], "settings.a"); dict ["b"] = 2; using (IsolatedStorageFileStream fs = new IsolatedStorageFileStream ("__LocalSettings", FileMode.Create, isf)) { using (StreamReader sr = new StreamReader (fs)) { DataContractSerializer writer = new DataContractSerializer (dict.GetType ()); writer.WriteObject (fs, dict); } } // saved but not re-loaded Assert.AreEqual (1, settings.Count, "Count"); settings.Clear (); }
// Interception bouton back protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e) { store.Save(); e.Cancel = true; NavigationService.GoBack(); }