-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSettingsManagerWP81.cs
42 lines (35 loc) · 1.08 KB
/
SettingsManagerWP81.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
using System;
using System.IO.IsolatedStorage;
// It is simple manager to save info in IsolatedStorage
// Can be used in WP projects, for example
// I use it for the our WinGym project.
public static class SettingsManager {
static ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
public static T GetSettings<T>( string propertie ) {
T temp = default( T );
if ( localSettings.Values.ContainsKey( propertie ) )
{
temp = (T) localSettings.Values[propertie];
}
else {
localSettings.Values.Add( propertie, default( T ) );
}
return temp;
}
public static T GetSettings<T>( string propertie, T defaultvalue ) {
T temp = defaultvalue;
if ( localSettings.Values.ContainsKey( propertie ) ) {
temp = ( T ) localSettings.Values[ propertie ];
}
else {
localSettings.Values.Add( propertie, defaultvalue );
}
return temp;
}
public static void SaveSettings<T>( string propertie, T value ) {
try {
localSettings.Values[ propertie ] = value;
}
catch ( Exception e ) {
}
}