﻿using JLGames.RocketDriver.CSharp.Utils;

namespace JLGames.RocketDriver.Actions.ExcelExporter
{
    /// <summary>
    /// Used to explain the json data file generated by the tool "ExcelExporter"
    /// The tool link is: https://github.com/xuzhuoxi/ExcelExporter
    /// 用于解释工具《ExcelExporter》生成的json数据文件
    /// 工具链接为：https://github.com/xuzhuoxi/ExcelExporter
    /// </summary>
    public class ExtCfgTitle<TCfgTitle>
    {
        private int m_Id;
        private TCfgTitle m_RawData;

        //------------------------------

        public string Key => $"{m_Id}";
        public int Id => m_Id;
        public TCfgTitle RawData => m_RawData;

        public void SetData(TCfgTitle rawData, string idName = "Id")
        {
            m_RawData = rawData;
            m_Id = GetId(idName);
            if (0 == m_Id)
            {
                return;
            }

            HandleData();
        }

        private int GetId(string idName)
        {
            return m_RawData.GetPropertyInt(idName);
        }

        protected virtual void HandleData()
        {
        }
    }
}