using ConfigOperator;
using RealtimeData;
using System.IO;

namespace AlarmInfoServerSim.Services;

public class SharedConfig : ISharedConfig
{
    private BasicInfo? _basicInfo;
    private Hardwares? _hardwares;
    public SharedConfig()
    {
        string basicInfoPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Settings", "Base", "BasicInfo.xml");
        if (!BaseConfigFileLoader.Load(basicInfoPath, out _basicInfo) || _basicInfo is null)
        {
            //log
        }

        string hardwaresPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Settings", "Hardwares");
        _hardwares = new Hardwares();
        HardwareFileLoader hardwareFileLoader = new HardwareFileLoader(_hardwares);
        if (!hardwareFileLoader.Load(hardwaresPath))
        {
            _hardwares = null;
            //log
        }
    }

    public BasicInfo? BasicInfo => _basicInfo;

    public Hardwares? Hardwares => _hardwares;
}
