예제 #1
0
 public static SiteConfigInfo Serialize(SiteConfigInfo configinfo, string path)
 {
     lock (m_lockHelper)
     {
         SerializationHelper.Save(configinfo, path);
     }
     return(configinfo);
 }
예제 #2
0
 /// <summary>
 /// 序列化配置信息为XML
 /// </summary>
 /// <param name="configinfo">配置信息</param>
 /// <param name="configFilePath">配置文件完整路径</param>
 public static SiteConfigInfo Serialiaze(SiteConfigInfo configinfo, string configFilePath)
 {
     lock (lockHelper)
     {
         SerializationHelper.Save(configinfo, configFilePath);
     }
     return(configinfo);
 }
예제 #3
0
        public static SiteConfigInfo GetConfig()
        {
            SiteConfigInfo config = null;

            if (config == null)
            {
                config = SiteConfigFileManager.LoadConfig();
            }
            return(config);
        }
예제 #4
0
        /// <summary>
        /// 保存配置到config文件
        /// </summary>
        /// <param name="configinfo"></param>
        /// <returns></returns>
        public static bool SaveConfig(SiteConfigInfo configinfo)
        {
            bool ret = false;

            lock (lockHelper)
            {
                ret = SerializationHelper.Save(configinfo, SiteConfigFileManager.ConfigFilePath);
                ResetConfig();
            }
            return(ret);
        }
예제 #5
0
        public static SiteConfigInfo LoadConfig()
        {
            try
            {
                if (ConfigInfo != null)
                {
                    m_fileoldchange = File.GetLastWriteTime(ConfigFilePath);
                    ConfigInfo      = DefaultConfigFileManager.LoadConfig(ref m_fileoldchange, ConfigFilePath, ConfigInfo, true);
                }
                else
                {
                    filename   = HttpContext.Current.Server.MapPath("~/Config/site.config");
                    ConfigInfo = new SiteConfigInfo();
                    ConfigInfo = DefaultConfigFileManager.LoadConfig(ref m_fileoldchange, ConfigFilePath, ConfigInfo, false);
                }
            }
            catch
            {
            }

            return(ConfigInfo as SiteConfigInfo);
        }
예제 #6
0
        /// <summary>
        /// 获取当前站点配置
        /// </summary>
        /// <returns></returns>
        public static SiteConfigInfo GetConfig()
        {
            //if (m_configinfo == null)
            //{
            //    lock (lockHelper)
            //    {
            //        if (m_configinfo == null)
            //        {
            //            m_configinfo = SiteConfigFileManager.LoadConfig();
            //        }
            //    }
            //}
            //return m_configinfo;

            string         configid = "siteconfig";
            SiteConfigInfo config   = AppCtx.Cache.RetrieveObject <SiteConfigInfo>(configid);

            if (config == null)
            {
                config = SiteConfigFileManager.LoadConfig();
                AppCtx.Cache.AddObjectWithFileChange(configid, config, ConfigFile);
            }
            return(config);
        }
예제 #7
0
 /// <summary>
 /// 重设配置类实例
 /// </summary>
 public static void ResetConfig()
 {
     m_configinfo = SiteConfigFileManager.LoadRealConfig();
 }