Removing duplicated extension for creating enumerable configuration
This commit is contained in:
parent
0d737d5eb8
commit
06cfdcaf23
|
|
@ -1,34 +0,0 @@
|
|||
// 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.Collections.Generic;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace Microsoft.AspNetCore.Hosting.Internal
|
||||
{
|
||||
public static class IConfigurationExtensions
|
||||
{
|
||||
// Temporary until Configuration/issues/370 is implemented.
|
||||
public static IEnumerable<KeyValuePair<string, string>> GetFlattenedSettings(this IConfiguration configuration)
|
||||
{
|
||||
var stack = new Stack<IConfiguration>();
|
||||
stack.Push(configuration);
|
||||
|
||||
while (stack.Count > 0)
|
||||
{
|
||||
var config = stack.Pop();
|
||||
var section = config as IConfigurationSection;
|
||||
|
||||
if (section != null)
|
||||
{
|
||||
yield return new KeyValuePair<string, string>(section.Path, section.Value);
|
||||
}
|
||||
|
||||
foreach (var child in config.GetChildren())
|
||||
{
|
||||
stack.Push(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -24,7 +24,7 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
|
||||
public static IWebHostBuilder UseConfiguration(this IWebHostBuilder builder, IConfiguration configuration)
|
||||
{
|
||||
foreach (var setting in configuration.GetFlattenedSettings())
|
||||
foreach (var setting in configuration.AsEnumerable())
|
||||
{
|
||||
builder.UseSetting(setting.Key, setting.Value);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue