public static void saveUserSettings(Settings settings) { using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) { //If user choose to save, create a new file using (IsolatedStorageFileStream fs = isf.CreateFile("user.dat")) { //and serialize data XmlSerializer ser = new XmlSerializer(typeof(Settings)); ser.Serialize(fs, settings); } } }
// Code to execute when the application is launching (eg, from Start) // This code will not execute when the application is reactivated private void Application_Launching(object sender, LaunchingEventArgs e) { var settings = new Settings(); // Check if user data has been saved - if so pre-load values using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) { if(isf.FileExists("refu.dat")) { using(IsolatedStorageFileStream fs = isf.OpenFile("refu.dat", System.IO.FileMode.Open)) { XmlSerializer ser = new XmlSerializer(typeof(Settings)); object obj = ser.Deserialize(fs); if(obj != null && obj is Settings) { settings = obj as Settings; } else { settings = new Settings(); } } } else { settings = new Settings(); } } RootFrame.DataContext = settings; }
public static LoginStatus login(Settings settings) { //TODO: Login code + encryption return LoginStatus.SUCCESS; }