using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Aitex.Core.RT.Log;
namespace Aitex.Core.RT.ConfigCenter
{
    public class ConfigItem
    {
        public object this[string configName]
        {
            get
            {
                return CONFIG.Get(configName);
            }
            set
            {
                CONFIG.Set(configName, value);
            }
        }
    }
    public class CONFIG
    {
        public static ConfigItem Items = new ConfigItem();
        public static ICommonConfig InnerConfigManager { set; private get; }
        public static object Get(string configName)
        {
            return (InnerConfigManager != null) ? InnerConfigManager.GetConfig(configName) : null;
        }
        public static void Set(string configName, object value)
        {
            if (InnerConfigManager != null)
                InnerConfigManager.SetConfig(configName, value);
        }
        /// 
        /// 返回Config目录下面文件的内容,filename也可以是绝对路径
        /// 如果文件不存在,返回NULL。
        /// 如果读取错误,返回""
        /// 
        /// 
        /// 
        public static string GetFileContent(string fileName)
        {
            if (InnerConfigManager != null)
                return InnerConfigManager.GetFileContent(fileName);
            //LOG.Error("Config模块没有初始化,调用GetConfigFile()" + fileName);
            return null;
        }
        public static void Subscribe(string module, string key, Func