-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathConfiguration.cs
More file actions
68 lines (62 loc) · 2.24 KB
/
Configuration.cs
File metadata and controls
68 lines (62 loc) · 2.24 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System;
using System.Configuration;
namespace SendPushoverNotification
{
public static class Configuration
{
public static class Pushover
{
public static string Url
{
get
{
var url = ConfigurationManager.AppSettings.Get ("PushoverUrl");
if(string.IsNullOrWhiteSpace(url))
throw new ConfigurationErrorsException("Pushover URL must be configured.");
Uri uri;
if (!Uri.TryCreate (url, UriKind.Absolute, out uri))
{
var badUrlMessage = string.Format ("Configured Pushover URL is not a valid URL: {0}", url);
throw new ConfigurationErrorsException (badUrlMessage);
}
return url;
}
}
public static string Token
{
get
{
var token = ConfigurationManager.AppSettings.Get ("PushoverToken");
if(string.IsNullOrWhiteSpace(token))
throw new ConfigurationErrorsException("Pushover Token must be configured.");
return token;
}
}
public static string User
{
get
{
var user = ConfigurationManager.AppSettings.Get ("PushoverUser");
if(string.IsNullOrWhiteSpace(user))
throw new ConfigurationErrorsException("Pushover User must be configured.");
return user;
}
}
}
public static class NetworkProxy
{
public static bool UseNetworkProxy
{
get { return bool.Parse(ConfigurationManager.AppSettings.Get("UseNetworkProxy")); }
}
public static string Server
{
get { return ConfigurationManager.AppSettings.Get("NetworkProxyServer"); }
}
public static int Port
{
get { return int.Parse(ConfigurationManager.AppSettings.Get("NetworkProxyPort")); }
}
}
}
}