58 lines
1.3 KiB
C#
58 lines
1.3 KiB
C#
namespace InspectionUI.Models
|
|
{
|
|
using System.Configuration;
|
|
using System.IO;
|
|
|
|
public class Appsettings
|
|
{
|
|
private static string ExeFilePath
|
|
{
|
|
get => typeof(App).Assembly.Location;
|
|
}
|
|
|
|
private static Configuration ExeConfiguration
|
|
{
|
|
get => ConfigurationManager.OpenExeConfiguration(ExeFilePath);
|
|
}
|
|
|
|
private static KeyValueConfigurationCollection Settings
|
|
{
|
|
get => ExeConfiguration.AppSettings.Settings;
|
|
}
|
|
|
|
public static string CurrentDirectory
|
|
{
|
|
get => new FileInfo(ExeFilePath).DirectoryName;
|
|
}
|
|
|
|
public static string COMPorts
|
|
{
|
|
get => GetSetting(nameof(COMPorts));
|
|
}
|
|
|
|
public static string OmniDB
|
|
{
|
|
get => GetSetting(nameof(OmniDB));
|
|
}
|
|
|
|
public static string HubURL
|
|
{
|
|
get => GetSetting(nameof(HubURL));
|
|
}
|
|
|
|
public static string PSNR
|
|
{
|
|
get => GetSetting(nameof(PSNR));
|
|
}
|
|
|
|
private static string GetSetting(string setting)
|
|
{
|
|
var appsettingsSection = ExeConfiguration.AppSettings.SectionInformation.Name;
|
|
|
|
ConfigurationManager.RefreshSection(appsettingsSection);
|
|
|
|
return Settings[setting].Value;
|
|
}
|
|
}
|
|
}
|