-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGlobals.cs
More file actions
38 lines (31 loc) · 1.2 KB
/
Globals.cs
File metadata and controls
38 lines (31 loc) · 1.2 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
using System;
using System.Configuration;
namespace RemotePShell
{
internal static class Globals
{
public static string ServerAddress = FetchGlobalConfig("ServerAddress");
//Username used to login to the PS server
public static readonly string ServerUsername = FetchGlobalConfig("ServerUsername");
//password used to login to PS server
public static readonly string ServerPassword = FetchGlobalConfig("ServerPassword");
public static readonly string LogFolder = FetchGlobalConfig("LogFolder");
public static string FetchGlobalConfig(string key)
{
// Fetches the configuration 'key' from the App.Config settings file
string result;
try
{
var globalConfigs = ConfigurationManager.AppSettings;
result = globalConfigs[key] ?? "__Setting_Not_Found__";
Console.WriteLine("CONFIG LOADED - key: " + result);
}
catch (ConfigurationErrorsException)
{
Console.WriteLine("Error reading app settings");
result = "__Setting_Not_Found__";
}
return result;
}
}
}