示例#1
0
        /// <summary>
        /// 静态构造函数初始化相应实例和定时器
        /// </summary>
        static GlobalConfig()
        {
            _configinfo = GlobalBaseConfigFileManager.LoadConfig();

            generalConfigTimer.AutoReset = true;
            generalConfigTimer.Enabled = true;
            generalConfigTimer.Elapsed += new System.Timers.ElapsedEventHandler(Timer_Elapsed);
            generalConfigTimer.Start();
        }
        /// <summary>
        /// 初始化文件修改时间和对象实例
        /// </summary>
        static GlobalBaseConfigFileManager()
        {
            _fileoldchange = System.IO.File.GetLastWriteTime(ConfigFilePath);

            try
            {
                _configinfo = (GlobalConfigInfo)BaseConfigFileManager.DeserializeInfo(ConfigFilePath, typeof(GlobalConfigInfo));
            }
            catch
            {
                if (File.Exists(ConfigFilePath))
                {
                    _configinfo = (GlobalConfigInfo)BaseConfigFileManager.DeserializeInfo(ConfigFilePath, typeof(GlobalConfigInfo));
                }
            }
        }
示例#3
0
 /// <summary>
 /// 序列化配置信息为XML
 /// </summary>
 /// <param name="configinfo">配置信息</param>
 /// <param name="configFilePath">配置文件完整路径</param>
 public static GlobalConfigInfo Serialiaze(GlobalConfigInfo configinfo, string configFilePath)
 {
     lock (lockHelper)
     {
         SerializationHelper.Save(configinfo, configFilePath);
     }
     return configinfo;
 }
示例#4
0
 /// <summary>
 /// 保存配置类实例
 /// </summary>
 /// <param name="generalconfiginfo"></param>
 /// <returns></returns>
 public static bool SaveConfig(GlobalConfigInfo generalconfiginfo)
 {
     GlobalBaseConfigFileManager gcf = new GlobalBaseConfigFileManager();
     GlobalBaseConfigFileManager.ConfigInfo = generalconfiginfo;
     return gcf.SaveConfig();
 }
示例#5
0
 /// <summary>
 /// 重设配置类实例
 /// </summary>
 public static void ResetConfig()
 {
     _configinfo = GlobalBaseConfigFileManager.LoadConfig();
 }