/// <summary>
 /// 获取默认值
 /// </summary>
 /// <param name="value"></param>
 /// <param name="type"></param>
 /// <returns></returns>
 private object GetDefaultValue(object value, Type type)
 {
     try
     {
         //obj =  Convert.ChangeType(obj, type);
         value = AppSettingsBase.ChangeValueType(value, type);
     }
     catch (Exception)
     {
         value = default(object);
     }
     return(value);
 }
        /// <summary>
        /// 读取资源
        /// 如果抛出资源未释放异常,则尝试读取3次,每次间隔50ms
        /// 若再次抛出异常,则将此异常抛出,不再尝试
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="func"></param>
        /// <returns></returns>
        private static T LoadResource <T>(Func <T> func)
        {
            int tryCount = 0;

            while (true)
            {
                try
                {
                    return(func());
                }
                catch (Exception ex)
                {
                    tryCount++;
                    if (tryCount >= 3)
                    {
                        AppSettingsBase.Log(ex);
                        throw ex;
                    }
                    System.Threading.Thread.Sleep(50);
                }
            }
        }
        /// <summary>
        /// 加载自定义配置到缓存
        /// </summary>
        /// <param name="xmlSubPath">配置文件中的相对位置</param>
        /// <returns></returns>
        public List <TEntity> LoadToCache(string xmlSubPath = null)
        {
            try
            {
                var appSettings = GetAppSettings(xmlSubPath);
                if (HttpRuntime.Cache[Key] != null)
                {
                    HttpRuntime.Cache.Remove(Key);
                }

                if (appSettings != null && appSettings.Count > 0)
                {
                    CacheDependency cdd = new CacheDependency(XmlPaths); //缓存依赖文件
                    HttpRuntime.Cache.Insert(Key, appSettings, cdd, DateTime.MaxValue, Cache.NoSlidingExpiration);
                }
                return(appSettings);
            }
            catch (Exception ex)
            {
                AppSettingsBase.Log(ex);
                throw ex;
            }
        }