Removing duplicated extension for creating enumerable configuration

This commit is contained in:
John Luo 2016-02-25 17:38:11 -08:00
parent 0d737d5eb8
commit 06cfdcaf23
2 changed files with 1 additions and 35 deletions

View File

@ -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);
}
}
}
}
}

View File

@ -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);
}