38 lines
1.0 KiB
C#
38 lines
1.0 KiB
C#
namespace Common.UI.Infrastructure
|
|
{
|
|
using System;
|
|
using System.Configuration;
|
|
using System.Linq;
|
|
|
|
public static class Appsettings
|
|
{
|
|
private static readonly string dll = typeof(Appsettings).Assembly.Location;
|
|
|
|
public static string GetSetting(string settingKey)
|
|
{
|
|
var settingValue = default(string);
|
|
|
|
try
|
|
{
|
|
settingValue = ConfigurationManager
|
|
.OpenExeConfiguration(dll)
|
|
.AppSettings
|
|
.Settings[settingKey]
|
|
.Value;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
AppHost.NLogger.Error(e);
|
|
}
|
|
|
|
return settingValue;
|
|
}
|
|
|
|
public static string[] GetSIRTComPorts()
|
|
=> GetSetting("SIRTComPorts")
|
|
?.Split(new[] { ';', ',', ' ' }, StringSplitOptions.RemoveEmptyEntries)
|
|
?.Select(x => x?.Trim())
|
|
?.ToArray() ?? new string[0];
|
|
}
|
|
}
|