using JiShe.CollectBus.Protocol.Contracts.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using JiShe.CollectBus.Common.Extensions;

namespace JiShe.CollectBus.Protocol.Contracts
{
    public class QGDW3761Config
    {
        private static List<TB3761> _commandList = null;
        public static List<TB3761> CommandList
        {
            get
            {
                if (_commandList == null)
                {
                    var filePath = AppDomain.CurrentDomain.BaseDirectory + "cmd3761Matching.txt";
                  
                    try
                    {
                        var fileStr = "";
                        if (File.Exists(filePath))
                            fileStr = File.ReadAllText(filePath, Encoding.UTF8);
                       
                        if (!string.IsNullOrWhiteSpace(fileStr))
                        {
                            _commandList = fileStr.FromJson<List<TB3761>>();
                        }
                    }
                    catch (Exception)
                    {

                    }
                }
                return _commandList;
            }
        }

        private static List<TB3761> _commandTdcList = null;
        public static List<TB3761> CommandTdcList
        {
            get
            {
                if (_commandTdcList == null)
                {
                    var filePath = AppDomain.CurrentDomain.BaseDirectory + "cmd3761TdcMatching.txt";

                    try
                    {
                        var fileStr = "";
                        if (File.Exists(filePath))
                            fileStr = File.ReadAllText(filePath, Encoding.UTF8);

                        if (!string.IsNullOrWhiteSpace(fileStr))
                        {
                            _commandTdcList = fileStr.FromJson<List<TB3761>>();
                        }
                    }
                    catch (Exception)
                    {

                    }
                }
                return _commandTdcList;
            }
        }
    }
}
