// Reference : http://www.geekchamp.com/tips/all-about-wp7-isolated-storage-store-data-in-isolatedstoragesettings /// <summary> /// Saves the logged user. /// </summary> /// <param name="user">The user.</param> /// <returns></returns> public bool SaveLoggedUser(User user) { if ((user != null) && (!user.HasNullOrEmpty()) && (!settings.Contains(userKeyword))) { Debug.WriteLine(DebugInfo.Format(DateTime.Now, this, MethodInfo.GetCurrentMethod(), String.Format("Adding user {0} to storage.", user.username))); settings.Add(userKeyword, user); // TDOD Localize string OnUserChanged(new ApplicationEventArgs(String.Format("User {0} has been saved.", user.username), ApplicationError.SUCCESS)); return true; } return false; }
/// <summary> /// Retrives the logged user. /// </summary> /// <returns></returns> public User RetriveLoggedUser() { Debug.WriteLineIf(!settings.Contains(userKeyword), DebugInfo.Format(DateTime.Now, this, MethodInfo.GetCurrentMethod(), "IsolatedStorageSettings does NOT contain user.")); Debug.WriteLineIf(!settings.Contains(userKeyword), DebugInfo.Format(DateTime.Now, this, MethodInfo.GetCurrentMethod(), "IsolatedStorageSettings DOES contain user.")); User user = new User(); if (settings.Contains(userKeyword)) { settings.TryGetValue<User>(userKeyword, out user); } return user; }