blob: 8f8e36625697c4990acc8e00818e574936d63395 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
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<string>("user", out userName);
IsolatedStorageSettings.ApplicationSettings.TryGetValue<string>("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());
}
}
}
|