-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSettingsManagerWP80.cs
55 lines (48 loc) · 1.48 KB
/
SettingsManagerWP80.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
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;
// It is simple manager to save info in IsolatedStorage
// Can be used in WP 8.0 projects, for example. But for 8.1 I will rework it for using new stuff.
// I use it for the our WinGym project.
public static class SettingsManager
{
readonly static IsolatedStorageSettings _settings = IsolatedStorageSettings.ApplicationSettings;
public static T GetSettings<T>(string propertie)
{
T temp = default(T);
if (_settings.Contains(propertie))
{
temp = (T)_settings[propertie];
}
else
{
_settings.Add(propertie, default(T));
_settings.Save();
}
return temp;
}
public static T GetSettings<T>(string propertie, T defaultvalue)
{
T temp = defaultvalue;
if (_settings.Contains(propertie))
{
temp = (T)_settings[propertie];
}
else
{
_settings.Add(propertie, defaultvalue);
_settings.Save();
}
return temp;
}
public static void SaveSettings<T>(string propertie, T value)
{
try
{
_settings[propertie] = value;
_settings.Save();
}
catch (Exception e)
{
}
}
}