root / trunk / Pithos.Client.WPF / Configuration / PithosSettings.cs @ f734ab5b
History | View | Annotate | Download (4.4 kB)
1 |
// ----------------------------------------------------------------------- |
---|---|
2 |
// <copyright file="PithosSettings.cs" company="Microsoft"> |
3 |
// TODO: Update copyright text. |
4 |
// </copyright> |
5 |
// ----------------------------------------------------------------------- |
6 |
|
7 |
using System.ComponentModel.Composition; |
8 |
using System.Configuration; |
9 |
using System.Dynamic; |
10 |
using Pithos.Client.WPF.Properties; |
11 |
using Pithos.Interfaces; |
12 |
|
13 |
namespace Pithos.Client.WPF.Configuration |
14 |
{ |
15 |
using System; |
16 |
using System.Collections.Generic; |
17 |
using System.Linq; |
18 |
using System.Text; |
19 |
|
20 |
[Export(typeof(IPithosSettings))] |
21 |
[Export] |
22 |
public class PithosSettings : IPithosSettings |
23 |
{ |
24 |
private readonly Settings _settings = Settings.Default; |
25 |
|
26 |
public bool UseDefaultProxy |
27 |
{ |
28 |
get { return _settings.UseDefaultProxy; } |
29 |
set { _settings.UseDefaultProxy = value; } |
30 |
} |
31 |
|
32 |
public bool UseManualProxy |
33 |
{ |
34 |
get { return _settings.UseManualProxy; } |
35 |
set { _settings.UseManualProxy = value; } |
36 |
} |
37 |
|
38 |
public bool UseNoProxy |
39 |
{ |
40 |
get { return _settings.UseNoProxy; } |
41 |
set { _settings.UseNoProxy = value; } |
42 |
} |
43 |
|
44 |
public string PithosPath |
45 |
{ |
46 |
get { return _settings.PithosPath; } |
47 |
set { _settings.PithosPath = value; } |
48 |
} |
49 |
|
50 |
/* public string PithosSite |
51 |
{ |
52 |
get { return _settings.PithosSite; } |
53 |
}*/ |
54 |
|
55 |
public string PithosLoginUrl |
56 |
{ |
57 |
get { return _settings.PithosLoginUrl; } |
58 |
} |
59 |
|
60 |
public string IconsPath |
61 |
{ |
62 |
get { return _settings.IconPath; } |
63 |
set { _settings.IconPath = value; } |
64 |
} |
65 |
|
66 |
public string UserName |
67 |
{ |
68 |
get { return _settings.UserName; } |
69 |
set { _settings.UserName = value; } |
70 |
} |
71 |
|
72 |
public string ApiKey |
73 |
{ |
74 |
get { return _settings.ApiKey; } |
75 |
set { _settings.ApiKey = value; } |
76 |
} |
77 |
|
78 |
public AccountsCollection Accounts |
79 |
{ |
80 |
get |
81 |
{ |
82 |
if (_settings.Accounts==null) |
83 |
_settings.Accounts=new AccountsCollection(); |
84 |
return _settings.Accounts; |
85 |
} |
86 |
set { _settings.Accounts = value; } |
87 |
} |
88 |
|
89 |
public string ProxyServer |
90 |
{ |
91 |
get { return _settings.ProxyServer; } |
92 |
set { _settings.ProxyServer = value; } |
93 |
} |
94 |
|
95 |
public int ProxyPort |
96 |
{ |
97 |
get { return _settings.ProxyPort; } |
98 |
set { _settings.ProxyPort = value; } |
99 |
} |
100 |
|
101 |
public string ProxyUsername |
102 |
{ |
103 |
get { return _settings.ProxyUsername; } |
104 |
set { _settings.ProxyUsername = value; } |
105 |
} |
106 |
|
107 |
|
108 |
public string ProxyPassword |
109 |
{ |
110 |
get { return _settings.ProxyPassword; } |
111 |
set { _settings.ProxyPassword = value; } |
112 |
} |
113 |
|
114 |
public bool ProxyAuthentication |
115 |
{ |
116 |
|
117 |
get { return _settings.ProxyAuthentication; } |
118 |
set { _settings.ProxyAuthentication = value; } |
119 |
} |
120 |
|
121 |
|
122 |
|
123 |
public bool ExtensionsActivated |
124 |
{ |
125 |
|
126 |
get { return _settings.ExtensionsActivated; } |
127 |
set { _settings.ExtensionsActivated = value; } |
128 |
} |
129 |
|
130 |
public bool ShowDesktopNotifications |
131 |
{ |
132 |
get { return _settings.ShowDesktopNotifications; } |
133 |
set { _settings.ShowDesktopNotifications = value; } |
134 |
} |
135 |
/* |
136 |
public override IEnumerable<string> GetDynamicMemberNames() |
137 |
{ |
138 |
return (from SettingsProperty property in _settings.Properties |
139 |
select property.Name); |
140 |
} |
141 |
|
142 |
|
143 |
private Lazy<ILookup<string, SettingsProperty>> _propertyNames = new Lazy<ILookup<string, SettingsProperty>>( |
144 |
() => (from SettingsProperty property in |
145 |
_settings.Properties |
146 |
select property).ToLookup(property => property.Name)); |
147 |
|
148 |
public override bool TryGetMember(GetMemberBinder binder, out object result) |
149 |
{ |
150 |
result = null; |
151 |
if (!_propertyNames.Value.Contains(binder.Name)) |
152 |
return false; |
153 |
result=_settings.Properties[binder.Name]; |
154 |
return true; |
155 |
} |
156 |
*/ |
157 |
|
158 |
public void Save() |
159 |
{ |
160 |
_settings.Save(); |
161 |
} |
162 |
|
163 |
public void Reload() |
164 |
{ |
165 |
_settings.Reload(); |
166 |
} |
167 |
} |
168 |
} |