Revize d0cf9476
Přidáno uživatelem Pultak před asi 3 roky(ů)
ld_client/LDClient/LDClient.csproj | ||
---|---|---|
7 | 7 |
<Nullable>enable</Nullable> |
8 | 8 |
</PropertyGroup> |
9 | 9 |
|
10 |
<ItemGroup> |
|
11 |
<None Remove="appsettings.json" /> |
|
12 |
</ItemGroup> |
|
13 |
|
|
14 |
<ItemGroup> |
|
15 |
<EmbeddedResource Include="appsettings.json"> |
|
16 |
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
|
17 |
</EmbeddedResource> |
|
18 |
</ItemGroup> |
|
19 |
|
|
10 | 20 |
<ItemGroup> |
11 | 21 |
<Reference Include="t32apinet"> |
12 | 22 |
<HintPath>..\dotnet\t32apinet\bin\Release\t32apinet.dll</HintPath> |
... | ... | |
14 | 24 |
</ItemGroup> |
15 | 25 |
|
16 | 26 |
<ItemGroup> |
17 |
<Folder Include="NewFolder\" /> |
|
27 |
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" /> |
|
28 |
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.0" /> |
|
18 | 29 |
</ItemGroup> |
19 | 30 |
|
20 | 31 |
</Project> |
ld_client/LDClient/appsettings.json | ||
---|---|---|
1 |
{ |
|
2 |
"Logging": { |
|
3 |
"ColorConsole": { |
|
4 |
"LogLevels": { |
|
5 |
"Information": "DarkGreen", |
|
6 |
"Warning": "Cyan", |
|
7 |
"Error": "Red" |
|
8 |
} |
|
9 |
}, |
|
10 |
"LogChunkSize": 1000, |
|
11 |
"LogChunkMaxCount": 1, |
|
12 |
"LogArchiveMaxCount": 1, |
|
13 |
"LogCleanupPeriod": 1000, |
|
14 |
"LogVerbosityType": 2, |
|
15 |
"LogFlowType": 1 |
|
16 |
} |
|
17 |
} |
ld_client/LDClient/utils/ConfigLoader.cs | ||
---|---|---|
1 |
using System; |
|
2 |
using System.Collections.Generic; |
|
3 |
using System.Configuration; |
|
4 |
using System.Linq; |
|
5 |
using System.Text; |
|
6 |
using System.Threading.Tasks; |
|
7 |
using Microsoft.Extensions.Configuration; |
|
8 |
using Microsoft.Extensions.Configuration.Json; |
|
9 |
|
|
10 |
namespace LDClient { |
|
11 |
internal class ConfigurationLoader { |
|
12 |
|
|
13 |
private readonly string LOGGING_SECTION = "Logging"; |
|
14 |
|
|
15 |
|
|
16 |
public int LogChunkSize { get; set; } |
|
17 |
public int LogChunkMaxCount { get; set; } |
|
18 |
public int LogArchiveMaxCount { get; set; } |
|
19 |
|
|
20 |
public int LogCleanupPeriod { get; set; } |
|
21 |
|
|
22 |
private LogVerbosity _logVerbosity = LogVerbosity.Full; |
|
23 |
public LogVerbosity LogVerbosityType { |
|
24 |
get { |
|
25 |
return _logVerbosity; |
|
26 |
} |
|
27 |
set |
|
28 |
{ _logVerbosity = value; |
|
29 |
} |
|
30 |
} |
|
31 |
|
|
32 |
private LogFlow _logFlowType = LogFlow.Console; |
|
33 |
public LogFlow LogFlowType { |
|
34 |
get { |
|
35 |
return _logFlowType; |
|
36 |
} |
|
37 |
set { |
|
38 |
_logFlowType = value; |
|
39 |
} |
|
40 |
} |
|
41 |
|
|
42 |
public ConfigurationLoader() { |
|
43 |
var configuration = new ConfigurationBuilder() |
|
44 |
.AddJsonFile("appsettings.json") |
|
45 |
.Build(); |
|
46 |
ReadAllSettings(configuration); |
|
47 |
} |
|
48 |
|
|
49 |
void ReadAllSettings(IConfigurationRoot configuration) { |
|
50 |
|
|
51 |
try { |
|
52 |
var logging = configuration.GetSection(LOGGING_SECTION); |
|
53 |
//TODO: Exception handling |
|
54 |
LogChunkSize = Int32.Parse(logging["LogChunkSize"]); |
|
55 |
LogChunkMaxCount = Int32.Parse(logging["LogChunkMaxCount"]); |
|
56 |
LogArchiveMaxCount = Int32.Parse(logging["LogArchiveMaxCount"]); |
|
57 |
LogCleanupPeriod = Int32.Parse(logging["LogCleanupPeriod"]); |
|
58 |
LogFlowType = (LogFlow)Int32.Parse(logging["LogFlowType"]); |
|
59 |
LogVerbosityType = (LogVerbosity)Int32.Parse(logging["LogVerbosityType"]); |
|
60 |
|
|
61 |
|
|
62 |
Console.WriteLine("Configuration successfully loaded!"); |
|
63 |
} catch (FormatException e) { |
|
64 |
//Console.WriteLine("Error reading app settings"); |
|
65 |
//TODO: remove stacktrace print in production |
|
66 |
Console.WriteLine("Error during reading of configuration occured!" + e); |
|
67 |
throw new IOException("Reading of configuration file failed! " + e); |
|
68 |
} |
|
69 |
} |
|
70 |
|
|
71 |
} |
|
72 |
} |
ld_client/LauterbachDebuggerClient.sln | ||
---|---|---|
5 | 5 |
MinimumVisualStudioVersion = 10.0.40219.1 |
6 | 6 |
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LDClient", "LDClient\LDClient.csproj", "{26616C14-A61B-4611-8CD0-D29837FA34E7}" |
7 | 7 |
EndProject |
8 |
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LDClientTests", "LDClientTests\LDClientTests.csproj", "{5A1DB888-70E5-41E8-A900-FC22B51727F8}"
|
|
8 |
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LDClientTests", "LDClientTests\LDClientTests.csproj", "{5A1DB888-70E5-41E8-A900-FC22B51727F8}"
|
|
9 | 9 |
EndProject |
10 | 10 |
Global |
11 | 11 |
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
Také k dispozici: Unified diff
re #9440 initial config manager definition