Statistics
| Branch: | Revision:

root / trunk / Pithos.ShellExtensions / ShellSettings.cs @ 5120f3cb

History | View | Annotate | Download (3.9 kB)

1
// -----------------------------------------------------------------------
2
// <copyright file="ShellSettings.cs" company="Microsoft">
3
// TODO: Update copyright text.
4
// </copyright>
5
// -----------------------------------------------------------------------
6

    
7
using System.ComponentModel.Composition;
8
using System.Diagnostics;
9
using System.ServiceModel;
10
using Microsoft.Win32;
11
using Pithos.Interfaces;
12

    
13
namespace Pithos.ShellExtensions
14
{
15
    using System;
16
    using System.Collections.Generic;
17
    using System.Linq;
18
    using System.Text;
19

    
20
    /// <summary>
21
    /// TODO: Update summary.
22
    /// </summary>
23
    [Export(typeof(IPithosSettings))]
24
    public class ShellSettings:IPithosSettings
25
    {
26
        private Lazy<IPithosSettings> _settings;
27
        public ShellSettings()
28
        {
29
            _settings = new Lazy<IPithosSettings>(LoadSettings);
30
        }
31

    
32
        public bool UseDefaultProxy
33
        {
34
            get { return _settings.Value.UseDefaultProxy; }
35
            set { _settings.Value.UseDefaultProxy = value; }
36
        }
37

    
38
        public bool UseManualProxy
39
        {
40
            get { return _settings.Value.UseManualProxy; }
41
            set { _settings.Value.UseManualProxy = value; }
42
        }
43

    
44
        public bool UseNoProxy
45
        {
46
            get { return _settings.Value.UseNoProxy; }
47
            set { _settings.Value.UseNoProxy = value; }
48
        }
49

    
50
        public string PithosPath
51
        {
52
            get { return _settings.Value.PithosPath; }
53
            set { _settings.Value.PithosPath = value; }
54
        }
55

    
56
        public string PithosSite
57
        {
58
            get { return _settings.Value.PithosSite; }
59
        }
60

    
61
        public string IconsPath
62
        {
63
            get { return _settings.Value.IconsPath; }
64
            set { _settings.Value.IconsPath = value; }
65
        }
66

    
67
        public string UserName
68
        {
69
            get { return _settings.Value.UserName; }
70
            set { _settings.Value.UserName = value; }
71
        }
72

    
73
        public string ApiKey
74
        {
75
            get { return _settings.Value.ApiKey; }
76
            set { _settings.Value.ApiKey = value; }
77
        }
78

    
79
        public AccountsCollection Accounts
80
        {
81
            get { return _settings.Value.Accounts; }
82
            set { _settings.Value.Accounts = value; }
83
        }
84

    
85
        public string ProxyServer
86
        {
87
            get { return _settings.Value.ProxyServer; }
88
            set { _settings.Value.ProxyServer = value; }
89
        }
90

    
91
        public int ProxyPort
92
        {
93
            get { return _settings.Value.ProxyPort; }
94
            set { _settings.Value.ProxyPort = value; }
95
        }
96

    
97
        public string ProxyUsername
98
        {
99
            get { return _settings.Value.ProxyUsername; }
100
            set { _settings.Value.ProxyUsername = value; }
101
        }
102

    
103

    
104
        public string ProxyPassword
105
        {
106
            get { return _settings.Value.ProxyPassword; }
107
            set { _settings.Value.ProxyPassword = value; }
108
        }
109

    
110
        public bool ProxyAuthentication
111
        {
112

    
113
            get { return _settings.Value.ProxyAuthentication; }
114
            set { _settings.Value.ProxyAuthentication = value; }
115
        }
116

    
117
        public bool ExtensionsActivated
118
        {
119

    
120
            get { return _settings.Value.ExtensionsActivated; }
121
            set { _settings.Value.ExtensionsActivated = value; }
122
        }
123
        public void Save()
124
        {
125
           
126
        }
127

    
128
        public void Reload()
129
        {
130
            _settings=new Lazy<IPithosSettings>(LoadSettings);
131
        }
132

    
133
        private  IPithosSettings LoadSettings()
134
        {
135

    
136
            try
137
            {
138
                using (var client = PithosHost.GetSettingsClient())
139
                {
140
                    return client.GetSettings();
141
                }
142
            }
143
            catch (Exception exc)
144
            {
145
                Log.ErrorFormat("[ERROR] while loading settings:\r{0}",exc);
146
                _settings = new Lazy<IPithosSettings>(LoadSettings);
147
            }
148
            return null;
149
        }
150
    }
151
}