root / trunk / Pithos.Client.WPF / Configuration / PithosSettings.cs @ 65282d58
History | View | Annotate | Download (6.4 kB)
1 |
// ----------------------------------------------------------------------- |
---|---|
2 |
// <copyright file="PithosSettings.cs" company="GRNET"> |
3 |
// Copyright 2011 GRNET S.A. All rights reserved. |
4 |
// |
5 |
// Redistribution and use in source and binary forms, with or |
6 |
// without modification, are permitted provided that the following |
7 |
// conditions are met: |
8 |
// |
9 |
// 1. Redistributions of source code must retain the above |
10 |
// copyright notice, this list of conditions and the following |
11 |
// disclaimer. |
12 |
// |
13 |
// 2. Redistributions in binary form must reproduce the above |
14 |
// copyright notice, this list of conditions and the following |
15 |
// disclaimer in the documentation and/or other materials |
16 |
// provided with the distribution. |
17 |
// |
18 |
// THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS |
19 |
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
20 |
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
21 |
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR |
22 |
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
23 |
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 |
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
25 |
// USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
26 |
// AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
27 |
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
28 |
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 |
// POSSIBILITY OF SUCH DAMAGE. |
30 |
// |
31 |
// The views and conclusions contained in the software and |
32 |
// documentation are those of the authors and should not be |
33 |
// interpreted as representing official policies, either expressed |
34 |
// or implied, of GRNET S.A. |
35 |
// </copyright> |
36 |
// ----------------------------------------------------------------------- |
37 |
|
38 |
using System.ComponentModel.Composition; |
39 |
using System.Configuration; |
40 |
using System.Dynamic; |
41 |
using Pithos.Client.WPF.Properties; |
42 |
using Pithos.Interfaces; |
43 |
|
44 |
namespace Pithos.Client.WPF.Configuration |
45 |
{ |
46 |
using System; |
47 |
using System.Collections.Generic; |
48 |
using System.Linq; |
49 |
using System.Text; |
50 |
|
51 |
[Export(typeof(IPithosSettings))] |
52 |
[Export] |
53 |
public class PithosSettings : IPithosSettings |
54 |
{ |
55 |
private readonly Settings _settings = Settings.Default; |
56 |
|
57 |
public PithosSettings() |
58 |
{ |
59 |
_settings.Upgrade(); |
60 |
} |
61 |
|
62 |
public bool UseDefaultProxy |
63 |
{ |
64 |
get { return _settings.UseDefaultProxy; } |
65 |
set { _settings.UseDefaultProxy = value; } |
66 |
} |
67 |
|
68 |
public bool UseManualProxy |
69 |
{ |
70 |
get { return _settings.UseManualProxy; } |
71 |
set { _settings.UseManualProxy = value; } |
72 |
} |
73 |
|
74 |
public bool UseNoProxy |
75 |
{ |
76 |
get { return _settings.UseNoProxy; } |
77 |
set { _settings.UseNoProxy = value; } |
78 |
} |
79 |
|
80 |
public string PithosPath |
81 |
{ |
82 |
get { return _settings.PithosPath; } |
83 |
set { _settings.PithosPath = value; } |
84 |
} |
85 |
|
86 |
/* public string PithosSite |
87 |
{ |
88 |
get { return _settings.PithosSite; } |
89 |
}*/ |
90 |
|
91 |
public string PithosLoginUrl |
92 |
{ |
93 |
get { return _settings.PithosLoginUrl; } |
94 |
} |
95 |
|
96 |
public string IconsPath |
97 |
{ |
98 |
get { return _settings.IconPath; } |
99 |
set { _settings.IconPath = value; } |
100 |
} |
101 |
|
102 |
public string UserName |
103 |
{ |
104 |
get { return _settings.UserName; } |
105 |
set { _settings.UserName = value; } |
106 |
} |
107 |
|
108 |
public string ApiKey |
109 |
{ |
110 |
get { return _settings.ApiKey; } |
111 |
set { _settings.ApiKey = value; } |
112 |
} |
113 |
|
114 |
public AccountsCollection Accounts |
115 |
{ |
116 |
get |
117 |
{ |
118 |
if (_settings.Accounts==null) |
119 |
_settings.Accounts=new AccountsCollection(); |
120 |
return _settings.Accounts; |
121 |
} |
122 |
set { _settings.Accounts = value; } |
123 |
} |
124 |
|
125 |
public string ProxyServer |
126 |
{ |
127 |
get { return _settings.ProxyServer; } |
128 |
set { _settings.ProxyServer = value; } |
129 |
} |
130 |
|
131 |
public int ProxyPort |
132 |
{ |
133 |
get { return _settings.ProxyPort; } |
134 |
set { _settings.ProxyPort = value; } |
135 |
} |
136 |
|
137 |
public string ProxyUsername |
138 |
{ |
139 |
get { return _settings.ProxyUsername; } |
140 |
set { _settings.ProxyUsername = value; } |
141 |
} |
142 |
|
143 |
|
144 |
public string ProxyPassword |
145 |
{ |
146 |
get { return _settings.ProxyPassword; } |
147 |
set { _settings.ProxyPassword = value; } |
148 |
} |
149 |
|
150 |
public string ProxyDomain |
151 |
{ |
152 |
get { return _settings.ProxyDomain; } |
153 |
set { _settings.ProxyDomain = value; } |
154 |
} |
155 |
|
156 |
public bool ProxyAuthentication |
157 |
{ |
158 |
|
159 |
get { return _settings.ProxyAuthentication; } |
160 |
set { _settings.ProxyAuthentication = value; } |
161 |
} |
162 |
|
163 |
|
164 |
|
165 |
public bool ExtensionsActivated |
166 |
{ |
167 |
|
168 |
get { return _settings.ExtensionsActivated; } |
169 |
set { _settings.ExtensionsActivated = value; } |
170 |
} |
171 |
|
172 |
public bool ShowDesktopNotifications |
173 |
{ |
174 |
get { return _settings.ShowDesktopNotifications; } |
175 |
set { _settings.ShowDesktopNotifications = value; } |
176 |
} |
177 |
|
178 |
|
179 |
public int PollingInterval |
180 |
{ |
181 |
get { return _settings.PollingInterval; } |
182 |
set |
183 |
{ |
184 |
if (value <= 0) |
185 |
throw new ArgumentOutOfRangeException(); |
186 |
_settings.PollingInterval = value; |
187 |
} |
188 |
} |
189 |
/* |
190 |
public override IEnumerable<string> GetDynamicMemberNames() |
191 |
{ |
192 |
return (from SettingsProperty property in _settings.Properties |
193 |
select property.Name); |
194 |
} |
195 |
|
196 |
|
197 |
private Lazy<ILookup<string, SettingsProperty>> _propertyNames = new Lazy<ILookup<string, SettingsProperty>>( |
198 |
() => (from SettingsProperty property in |
199 |
_settings.Properties |
200 |
select property).ToLookup(property => property.Name)); |
201 |
|
202 |
public override bool TryGetMember(GetMemberBinder binder, out object result) |
203 |
{ |
204 |
result = null; |
205 |
if (!_propertyNames.Value.Contains(binder.Name)) |
206 |
return false; |
207 |
result=_settings.Properties[binder.Name]; |
208 |
return true; |
209 |
} |
210 |
*/ |
211 |
|
212 |
public void Save() |
213 |
{ |
214 |
_settings.Save(); |
215 |
} |
216 |
|
217 |
public void Reload() |
218 |
{ |
219 |
_settings.Reload(); |
220 |
} |
221 |
} |
222 |
} |