1 // -----------------------------------------------------------------------
2 // <copyright file="PithosSettings.cs" company="GRNET">
3 // Copyright 2011 GRNET S.A. All rights reserved.
5 // Redistribution and use in source and binary forms, with or
6 // without modification, are permitted provided that the following
9 // 1. Redistributions of source code must retain the above
10 // copyright notice, this list of conditions and the following
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.
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.
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.
36 // -----------------------------------------------------------------------
38 using System.ComponentModel.Composition;
39 using System.Configuration;
41 using Pithos.Client.WPF.Properties;
42 using Pithos.Interfaces;
44 namespace Pithos.Client.WPF.Configuration
47 using System.Collections.Generic;
51 [Export(typeof(IPithosSettings))]
53 public class PithosSettings : IPithosSettings
55 private readonly Settings _settings = Settings.Default;
57 public PithosSettings()
62 public bool UseDefaultProxy
64 get { return _settings.UseDefaultProxy; }
65 set { _settings.UseDefaultProxy = value; }
68 public bool UseManualProxy
70 get { return _settings.UseManualProxy; }
71 set { _settings.UseManualProxy = value; }
74 public bool UseNoProxy
76 get { return _settings.UseNoProxy; }
77 set { _settings.UseNoProxy = value; }
80 public string PithosPath
82 get { return _settings.PithosPath; }
83 set { _settings.PithosPath = value; }
86 /* public string PithosSite
88 get { return _settings.PithosSite; }
91 public string PithosLoginUrl
93 get { return _settings.PithosLoginUrl; }
96 public string IconsPath
98 get { return _settings.IconPath; }
99 set { _settings.IconPath = value; }
102 public string UserName
104 get { return _settings.UserName; }
105 set { _settings.UserName = value; }
110 get { return _settings.ApiKey; }
111 set { _settings.ApiKey = value; }
114 public AccountsCollection Accounts
118 if (_settings.Accounts==null)
119 _settings.Accounts=new AccountsCollection();
120 return _settings.Accounts;
122 set { _settings.Accounts = value; }
125 public string ProxyServer
127 get { return _settings.ProxyServer; }
128 set { _settings.ProxyServer = value; }
133 get { return _settings.ProxyPort; }
134 set { _settings.ProxyPort = value; }
137 public string ProxyUsername
139 get { return _settings.ProxyUsername; }
140 set { _settings.ProxyUsername = value; }
144 public string ProxyPassword
146 get { return _settings.ProxyPassword; }
147 set { _settings.ProxyPassword = value; }
150 public bool ProxyAuthentication
153 get { return _settings.ProxyAuthentication; }
154 set { _settings.ProxyAuthentication = value; }
159 public bool ExtensionsActivated
162 get { return _settings.ExtensionsActivated; }
163 set { _settings.ExtensionsActivated = value; }
166 public bool ShowDesktopNotifications
168 get { return _settings.ShowDesktopNotifications; }
169 set { _settings.ShowDesktopNotifications = value; }
173 public int PollingInterval
175 get { return _settings.PollingInterval; }
179 throw new ArgumentOutOfRangeException();
180 _settings.PollingInterval = value;
184 public override IEnumerable<string> GetDynamicMemberNames()
186 return (from SettingsProperty property in _settings.Properties
187 select property.Name);
191 private Lazy<ILookup<string, SettingsProperty>> _propertyNames = new Lazy<ILookup<string, SettingsProperty>>(
192 () => (from SettingsProperty property in
194 select property).ToLookup(property => property.Name));
196 public override bool TryGetMember(GetMemberBinder binder, out object result)
199 if (!_propertyNames.Value.Contains(binder.Name))
201 result=_settings.Properties[binder.Name];