/// <summary> /// Returns the requested config section using the current configuration source. /// </summary> public static T GetConfigSection <T>() where T : class, new() { if (TypesToScan == null) { return(ConfigurationSource.GetConfiguration <T>()); } var sectionOverrideType = TypesToScan.FirstOrDefault(t => typeof(IProvideConfiguration <T>).IsAssignableFrom(t)); if (sectionOverrideType == null) { return(ConfigurationSource.GetConfiguration <T>()); } var sectionOverride = (IProvideConfiguration <T>)Activator.CreateInstance(sectionOverrideType); return(sectionOverride.GetConfiguration()); }
/// <summary> /// Returns the requested config section using the current configuration source /// </summary> /// <typeparam name="T"></typeparam> /// <returns></returns> public static T GetConfigSection <T>() where T : class, new() { if (instance != null) { if (instance.configurer != null) { if (instance.configurer.HasComponent <IProvideConfiguration <T> >()) { var configSource = instance.Builder.Build <IProvideConfiguration <T> >(); if (configSource != null) { return(configSource.GetConfiguration()); } } } } return(ConfigurationSource.GetConfiguration <T>()); }