Skip to content
This repository has been archived by the owner on Dec 18, 2018. It is now read-only.

Add Clear() to IConfigurationBuilder #680

Closed
davidfowl opened this issue Jun 24, 2017 · 9 comments
Closed

Add Clear() to IConfigurationBuilder #680

davidfowl opened this issue Jun 24, 2017 · 9 comments
Assignees
Milestone

Comments

@davidfowl
Copy link
Member

This will make it possible to remove all registered providers and start over. Specifically, when using WebHost.CreateDefaultBuilder(), this would allow application code to change all previously configured options without losing the other benefits of calling that method.

/cc @glennc @divega @DamianEdwards @ajcvickers @HaoK

@DamianEdwards
Copy link
Member

Love it. Are there equivalents on the other builders we should also consider?

@HaoK
Copy link
Member

HaoK commented Jun 24, 2017

For the behavior, would Clear only clear the config sources, or also clear the Properties metadata that stores the base path/default file provider as well?

Maybe we should just change Sources to be an IList<IConfigurationSource> instead of IEnumerable, so people can clear/rearrange as desired, they already can modify Properties directly since its exposed as an Dictionary<string, object> Properties (??) already

https://github.com/aspnet/Configuration/blob/dev/src/Microsoft.Extensions.Configuration.Abstractions/IConfigurationBuilder.cs

@HaoK
Copy link
Member

HaoK commented Jun 24, 2017

I think in the past maybe we had special logic in Add, but its just a straight add now, so there's nothing that prevents us from exposing the ability for people to directly add to the sources

https://github.com/aspnet/Configuration/blob/dev/src/Microsoft.Extensions.Configuration/ConfigurationBuilder.cs#L38

@davidfowl
Copy link
Member Author

Maybe it should implement IList or ICollection

@shirhatti
Copy link

We discussed this in triage and we want Sources to be an IList<IConfigurationSource>

@davidfowl
Copy link
Member Author

@HaoK This is fixed right?

@HaoK
Copy link
Member

HaoK commented Jun 29, 2017

Yup, fixed via 6b4f1f8

@HaoK HaoK closed this as completed Jun 29, 2017
@HaoK HaoK added 3 - Done and removed 2 - Working labels Jun 29, 2017
@HaoK
Copy link
Member

HaoK commented Jun 29, 2017

builder.Sources.Clear()

@tugberkugurlu
Copy link

Amazing, just had a case to use this 🎉 Thanks for changing this!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants