Exemplo n.º 1
0
        public static IConfigurationSourceRoot AddIniFile([NotNull] this IConfigurationSourceRoot configuration, [NotNull] string path, bool optional)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentException(Resources.Error_InvalidFilePath, nameof(path));
            }

            var str = PathResolver.ResolveAppRelativePath(path);

            if (!optional && !File.Exists(str))
            {
                throw new FileNotFoundException(Resources.Error_FileNotFound, str);
            }

            configuration.Add(new IniFileConfigurationSource(path, optional));
            return(configuration);
        }