public static IEnumerable <IAppConfigurationSection> GetChildren(this IAppConfigurationRoot appConfig, string tenant) { if (string.IsNullOrEmpty(tenant)) { return(Enumerable.Empty <IAppConfigurationSection>()); } IAppConfigurationSection section = new TenantAppConfigurationSection(appConfig, tenant); return(section.GetChildren()); }
public IEnumerable <IAppConfigurationSection> GetChildren() { // We will loop through all of the global children and see if there is a tenant equivalent var children = new List <IAppConfigurationSection>(); var globalChildren = globalSection == null ? root.GetChildren() : globalSection.GetChildren(); foreach (IAppConfigurationSection globalChild in globalChildren) { if (globalChild.Path.Equals(tenant, StringComparison.OrdinalIgnoreCase)) { continue; } string tenantKey = AppConfigurationPath.Combine(tenant, globalChild.Path).ToLower(); // Tenant settings take precedence over global settings if (root.AllKeys.Contains(tenantKey)) { var tenantChild = root.GetSection(tenantKey); children.Add(tenantChild); } else { var tenantChild = new TenantAppConfigurationSection( root, AppConfigurationPath.Combine(tenant, globalChild.Path), tenant ); children.Add(tenantChild); } } return(children.AsReadOnly()); }