/// <summary> /// Adds a YAML configuration source to <paramref name="builder"/>. /// </summary> /// <param name="builder">The <see cref="IConfigurationBuilder"/> to add to.</param> /// <param name="provider">The <see cref="IFileProvider"/> to use to access the file.</param> /// <param name="path">Path relative to the base path stored in /// <see cref="IConfigurationBuilder.Properties"/> of <paramref name="builder"/>.</param> /// <param name="optional">Whether the file is optional.</param> /// <param name="reloadOnChange">Whether the configuration should be reloaded if the file changes.</param> /// <returns>The <see cref="IConfigurationBuilder"/>.</returns> public static IConfigurationBuilder AddYamlFile(this IConfigurationBuilder builder, IFileProvider provider, string path, bool optional, bool reloadOnChange) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } if (string.IsNullOrEmpty(path)) { throw new ArgumentException("Invalid File Path", nameof(path)); } if (provider == null && Path.IsPathRooted(path) && (!optional || File.Exists(path))) { provider = new PhysicalFileProvider(Path.GetDirectoryName(path)); path = Path.GetFileName(path); } var source = new YamlConfigurationSource { FileProvider = provider, Path = path, Optional = optional, ReloadOnChange = reloadOnChange }; builder.Add(source); return(builder); }
public YamlConfigurationProvider(YamlConfigurationSource source) : base(source) { }