Revize c2cc7813
Přidáno uživatelem Pultak před asi 2 roky(ů)
ld_client/LDClient/utils/ConfigLoader.cs | ||
---|---|---|
5 | 5 |
internal class ConfigLoader { |
6 | 6 |
private const string LoggingSection = "Logging"; |
7 | 7 |
private const string NetworkSection = "Network"; |
8 |
private const string CacheSection = "Cache"; |
|
9 |
private const string DDSection = "DebuggerDetection"; |
|
8 | 10 |
|
9 |
|
|
11 |
#region Logger |
|
10 | 12 |
public int LogChunkSize { get; set; } |
11 | 13 |
public int LogChunkMaxCount { get; set; } |
12 | 14 |
public int LogArchiveMaxCount { get; set; } |
... | ... | |
16 | 18 |
public LogVerbosity LogVerbosityType { get; set; } = LogVerbosity.Full; |
17 | 19 |
|
18 | 20 |
public LogFlow LogFlowType { get; set; } = LogFlow.Console; |
21 |
#endregion |
|
19 | 22 |
|
23 |
#region Api |
|
20 | 24 |
public string ApiBaseAddress { get; set; } |
21 | 25 |
public string ApiUsbEndPoint { get; set; } |
22 | 26 |
public uint ApiPort { get; set; } |
23 |
public uint ApiRetryPeriod { get; set; } |
|
24 | 27 |
|
28 |
#endregion |
|
29 |
|
|
30 |
#region Cache |
|
31 |
public string CacheFileName { get; set; } |
|
32 |
public uint MaxRetries { get; set; } |
|
33 |
public uint MaxEntries { get; set; } |
|
34 |
public uint RetryPeriod { get; set; } |
|
35 |
#endregion |
|
36 |
|
|
37 |
#region Detection |
|
25 | 38 |
public string DebuggerAddress { get; set; } |
26 | 39 |
public int DebuggerPort { get; set; } |
40 |
public string DebuggerProcessName { get; set; } |
|
41 |
#endregion |
|
27 | 42 |
|
28 | 43 |
public ConfigLoader() { |
29 | 44 |
var configuration = new ConfigurationBuilder() |
... | ... | |
48 | 63 |
ApiBaseAddress = network["ApiBaseAddress"]; |
49 | 64 |
ApiUsbEndPoint = network["ApiLDEndPoint"]; |
50 | 65 |
ApiPort = uint.Parse(network["ApiPort"]); |
51 |
ApiRetryPeriod = uint.Parse(network["ApiRetryPeriod"]); |
|
52 | 66 |
|
53 | 67 |
|
54 |
DebuggerAddress = network["DebuggerAddress"]; |
|
55 |
DebuggerPort = int.Parse(network["DebuggerPort"]); |
|
68 |
var cache = configuration.GetSection(CacheSection); |
|
69 |
RetryPeriod = uint.Parse(cache["RetryPeriod"]); |
|
70 |
MaxEntries = uint.Parse(cache["MaxEntries"]); |
|
71 |
MaxRetries = uint.Parse(cache["MaxRetries"]); |
|
72 |
CacheFileName = cache["CacheFileName"]; |
|
73 |
|
|
74 |
|
|
75 |
var debugger = configuration.GetSection(DDSection); |
|
76 |
DebuggerAddress = debugger["DebuggerAddress"]; |
|
77 |
DebuggerPort = int.Parse(debugger["DebuggerPort"]); |
|
78 |
DebuggerProcessName = debugger["DebuggerProcessName"]; |
|
56 | 79 |
|
57 | 80 |
Console.WriteLine("Configuration successfully loaded!"); |
58 | 81 |
} catch (FormatException e) { |
... | ... | |
62 | 85 |
throw new IOException("Reading of configuration file failed! " + e); |
63 | 86 |
} |
64 | 87 |
} |
65 |
|
|
66 | 88 |
} |
67 | 89 |
} |
Také k dispozici: Unified diff
re #9441 Added configuration properties + library added to project structure