markus / ConvertService / ServiceBase / Markus.Service.Extensions / Helper / ConfigHelper.cs @ 53c9637d
이력 | 보기 | 이력해설 | 다운로드 (1.19 KB)
1 |
using Salaros.Configuration; |
---|---|
2 |
using System; |
3 |
using System.Collections.Generic; |
4 |
using System.Globalization; |
5 |
using System.Linq; |
6 |
using System.Text; |
7 |
using System.Threading.Tasks; |
8 |
|
9 |
namespace Markus.Service.Helper |
10 |
{ |
11 |
public class ConfigHelper |
12 |
{ |
13 |
public static ConfigParser AppConfig(string ConfigFileName) |
14 |
{ |
15 |
string startDir = AppDomain.CurrentDomain.BaseDirectory; |
16 |
string configFilePath = ""; |
17 |
|
18 |
if (System.IO.Path.IsPathRooted(ConfigFileName)) |
19 |
{ |
20 |
configFilePath = $"{System.IO.Path.Combine(startDir, ConfigFileName)}"; |
21 |
} |
22 |
else |
23 |
{ |
24 |
configFilePath = ConfigFileName; |
25 |
} |
26 |
|
27 |
if(!System.IO.File.Exists(configFilePath)) |
28 |
{ |
29 |
throw new Exception($"Config File Not Found. {configFilePath}"); |
30 |
} |
31 |
|
32 |
return new ConfigParser(configFilePath, |
33 |
new ConfigParserSettings |
34 |
{ |
35 |
MultiLineValues = MultiLineValues.Simple | MultiLineValues.AllowValuelessKeys | MultiLineValues.QuoteDelimitedValues, |
36 |
Culture = new CultureInfo("en-US") |
37 |
}); |
38 |
} |
39 |
} |
40 |
} |