namespace ConfigOperator;

public class BaseConfigFileLoader
{
    public static string ConfigPath
    {
        get { return Path.Combine(Paths.BaseFolder, $"BasicInfo.xml"); }
    }

    public static bool Load(out BasicInfo? basicInfo)
    {
        if (!XmlHelper.DeserializeXml(ConfigPath, out basicInfo) || basicInfo is null)
            return false;

        return true;
    }

    public static void Save(BasicInfo basicInfo)
    {
        XmlFileHelper.WriteFile(ConfigPath, basicInfo);
    }
}

public class BasicInfo
{
    public string? DBConnectionString { get; set; }
    public string? ServerAddress { get; set; }
    public int ServerPort { get; set; }
    public int SelectedDisplay { get; set; }

    public string? RTServerAddress { get; set; }
    public ushort RTServerPort { get; set; }
    public string? GasPanelWindowName { get; set; }

    public DateTime DBClearTime { get; set; }
    public int DBKeepRange { get; set; }

    public int AlarmDelaySeconds { get; set; }
}