using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using 电子展板.Utility.Core;
using 电子展板.Utility.Extension;

namespace 电子展板.Base
{
    public class GlobalVariable
    {
        private static MyConfig _config;
        /// <summary>
        /// 配置数据
        /// </summary>
        public static MyConfig Config
        {
            get
            {
                if (_config == null)
                    _config = File.ReadAllText(MyEnvironment.Root("/Configs/Config.json")).ToObject<MyConfig>();
                return _config;
            }
            set
            {
                _config = value;
            }
        }

        public static void SaveConfig()
        {
            File.WriteAllText(MyEnvironment.Root("/Configs/Config.json"), Config.ToJson());
        }
    }
}
