예제 #1
0
        /// <summary>
        /// 获取指定的配置节中的配置
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="sectionKey"></param>
        /// <returns></returns>
        public static T GetConfigSection <T>(string sectionKey) where T : IConfigSection
        {
            var section = AppSettingsConfiguration.GetSection(sectionKey);

            if (null == section)
            {
                throw new Exception("Load ConfigSection failed,not set . ");
            }


            return(section.Get <T>());
        }
예제 #2
0
        //public static string GetConfigString(string key)
        //{
        //    return AppSettingsConfiguration.GetValue<string>(key);
        //}

        /// <summary>
        /// 数据库配置字符串信息
        /// </summary>
        /// <returns></returns>
        public static ConnectionStringSection GetConnectionStringSection()
        {
            var key     = ConnectionStringSection.SectionName;
            var section = AppSettingsConfiguration.GetSection(key);

            if (null == section)
            {
                throw new Exception("GetConnectionStringSection failed,not set ConnectionStringSection. ");
            }


            return(section.Get <ConnectionStringSection>());
        }
예제 #3
0
        /// <summary>
        /// App Key配置
        /// </summary>
        /// <returns></returns>
        public static AppSecretConfigSection GetAppKeyConfigSection()
        {
            var key     = AppSecretConfigSection.SectionName;
            var section = AppSettingsConfiguration.GetSection(key);

            if (null == section)
            {
                throw new Exception("AppTokenConfigSection failed,not set . ");
            }


            return(section.Get <AppSecretConfigSection>());
        }
예제 #4
0
        /// <summary>
        /// 获取配置蜘蛛节点信息
        /// </summary>
        /// <returns></returns>
        public static WebCrawlerSection GetWebCrawlerSection()
        {
            var key     = WebCrawlerSection.SectionName;
            var section = AppSettingsConfiguration.GetSection(key);

            if (null == section)
            {
                throw new Exception("GetWebCrawlerSection failed,not set WebCrawlerSection. ");
            }

            var configSection = section.Get <WebCrawlerSection>();

            return(configSection);
        }