forked from zcbenz/sbbs-client-wp7
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLocalCache.cs
30 lines (25 loc) · 810 Bytes
/
LocalCache.cs
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
using System.IO.IsolatedStorage;
namespace sbbs_client_wp7
{
public static class LocalCache
{
public static T Get<T>(string key, T defaultValue)
{
T value;
if (!IsolatedStorageSettings.ApplicationSettings.TryGetValue<T>(key, out value))
IsolatedStorageSettings.ApplicationSettings[key] = value = defaultValue;
return value;
}
public static T Get<T>(string key)
{
T value;
if (!IsolatedStorageSettings.ApplicationSettings.TryGetValue<T>(key, out value))
value = default(T);
return value;
}
public static void Set<T>(string key, T value)
{
IsolatedStorageSettings.ApplicationSettings[key] = value;
}
}
}