using System; using System.IO.IsolatedStorage; using System.Net; using System.Windows.Controls; namespace Juick.Classes { public class AccountManager { const string FileName = "account.xml"; public NetworkCredential Credentials { get { string userName; string password; IsolatedStorageSettings.ApplicationSettings.TryGetValue("user", out userName); IsolatedStorageSettings.ApplicationSettings.TryGetValue("password", out password); return new NetworkCredential { UserName = userName, Password = password, }; } set { var creds = value; if (creds != null) { IsolatedStorageSettings.ApplicationSettings["user"] = value.UserName; IsolatedStorageSettings.ApplicationSettings["password"] = value.Password; } else { IsolatedStorageSettings.ApplicationSettings["user"] = null; IsolatedStorageSettings.ApplicationSettings["password"] = null; } } } public void SignIn(Page page, string login, string pass, Uri nextUri) { Credentials = new NetworkCredential(login, pass); page.NavigationService.Navigate(nextUri); page.Dispatcher.BeginInvoke(() => page.NavigationService.RemoveBackEntry()); } public void SignOut(Page page) { Credentials = null; page.NavigationService.Navigate(new Uri("/LoginView.xaml", UriKind.Relative)); page.Dispatcher.BeginInvoke(() => page.NavigationService.RemoveBackEntry()); } } }