public JsonConfigurationSource([NotNull] string path, bool optional)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentException(Json.Resources.Error_InvalidFilePath, nameof(path));
            }

            Optional = optional;
            Path     = JsonPathResolver.ResolveAppRelativePath(path);
        }
Exemplo n.º 2
0
        public static IConfigurationSourceRoot AddJsonFile([NotNull] this IConfigurationSourceRoot configuration, [NotNull] string path, bool optional)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentException(Json.Resources.Error_InvalidFilePath, nameof(path));
            }

            var s = JsonPathResolver.ResolveAppRelativePath(path);

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

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