This commit is contained in:
Hao Kung 2017-09-05 11:22:47 -07:00
Родитель 875a72d74a
Коммит b5e0142e8b
3 изменённых файлов: 39 добавлений и 27 удалений

Просмотреть файл

@ -0,0 +1,35 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
namespace Microsoft.Extensions.Configuration
{
/// <summary>
/// IConfigurationBuilder extension methods for the chaind configuration provider.
/// </summary>
public static class ChainedBuilderExtensions
{
/// <summary>
/// Adds an existing configuration to <paramref name="configurationBuilder"/>.
/// </summary>
/// <param name="configurationBuilder">The <see cref="IConfigurationBuilder"/> to add to.</param>
/// <param name="config">The <see cref="IConfiguration"/> to add.</param>
/// <returns>The <see cref="IConfigurationBuilder"/>.</returns>
public static IConfigurationBuilder AddConfiguration(this IConfigurationBuilder configurationBuilder, IConfiguration config)
{
if (configurationBuilder == null)
{
throw new ArgumentNullException(nameof(configurationBuilder));
}
if (config == null)
{
throw new ArgumentNullException(nameof(config));
}
configurationBuilder.Add(new ChainedConfigurationSource { Configuration = config });
return configurationBuilder;
}
}
}

Просмотреть файл

@ -19,8 +19,6 @@ namespace Microsoft.Extensions.Configuration
/// <param name="builder">The <see cref="IConfigurationBuilder"/>.</param>
/// <returns>A <see cref="ChainedConfigurationProvider"/></returns>
public IConfigurationProvider Build(IConfigurationBuilder builder)
{
return new ChainedConfigurationProvider(this);
}
=> new ChainedConfigurationProvider(this);
}
}

Просмотреть файл

@ -8,31 +8,10 @@ using Microsoft.Extensions.Configuration.Memory;
namespace Microsoft.Extensions.Configuration
{
/// <summary>
/// IConfigurationBuilder extension methods.
/// IConfigurationBuilder extension methods for the MemoryConfigurationProvider.
/// </summary>
public static class ConfigurationBuilderExtensions
public static class MemoryConfigurationBuilderExtensions
{
/// <summary>
/// Adds an existing configuration to <paramref name="configurationBuilder"/>.
/// </summary>
/// <param name="configurationBuilder">The <see cref="IConfigurationBuilder"/> to add to.</param>
/// <param name="config">The <see cref="IConfiguration"/> to add.</param>
/// <returns>The <see cref="IConfigurationBuilder"/>.</returns>
public static IConfigurationBuilder AddConfiguration(this IConfigurationBuilder configurationBuilder, IConfiguration config)
{
if (configurationBuilder == null)
{
throw new ArgumentNullException(nameof(configurationBuilder));
}
if (config == null)
{
throw new ArgumentNullException(nameof(config));
}
configurationBuilder.Add(new ChainedConfigurationSource { Configuration = config });
return configurationBuilder;
}
/// <summary>
/// Adds the memory configuration provider to <paramref name="configurationBuilder"/>.
/// </summary>
@ -68,4 +47,4 @@ namespace Microsoft.Extensions.Configuration
return configurationBuilder;
}
}
}
}