private T ThrowConfigNotFoundException <T>(IEnumerable <string> targets)
     where T : class, new()
 => throw new Exception($"Unable to get configuration of type {typeof(T).Name}! "
                        + $"Configuration targets checked: {string.Join(",", targets)}, "
                        + $"path checked: [{searchPath}] ."
                        + $"Missing {TypeToSectionName(typeof(T))}."
                        + $"[{string.Join("|", configFileLocator.GetSupportedFileExtensions())}]?");
示例#2
0
        public T GetConfiguration <T>()
            where T : class, new()
        {
            CheckLoadConfiguration();

            T config;

            if ((config = TryGetCachedConfiguration <T>()) == null)
            {
                config = TryGetTypedConfiguration <T>();

                configurations[typeof(T)] = config
                                            ?? throw new Exception($"Unable to get configuration of type {typeof(T).Name}! " +
                                                                   $"Missing {TypeToSectionName(typeof(T))}." +
                                                                   $"[{string.Join("|", configFileLocator.GetSupportedFileExtensions())}]?");
            }

            return(config);
        }