Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to load configurations from IConfigurationSection/IConfigurationRoot #397

Merged
merged 32 commits into from
Oct 18, 2024

Conversation

alex-kulakov
Copy link
Contributor

Adds Load overloads to configuration classes of main project and some extensions.

Introduces a collection of configurations of extensions - DomainConfiguration.ExtensionConfigurations. Before that, extensions relied on default Load() methods which is not relevant today because App/Web.config files are outdated yet presented, now reading such configs is not easy and sometimes require a workaround. Also, there was no way to just create a configuration instance for some extension and use it to set up the settings. We allow it for main configuration but not for extensions. Being able to use configuration instances and "attach" them to domain configuration is a future-proof solution which can overcome further changes of .NET Configuration Files APIs.

Extensions' configurations are based on ConfigurationBase abstract type and can be locked. If any extension is developed outside ours and has some configuration then it can be based on ours ConfigurationBase and be placed to this unified collection and be expected there when it is needed.

Additionally, extension methods for DomainConfiguration added - ConfigureXxxExtension(), many variants available. They Load configuration from different APIs or just receive instance and put it to the collection of additional configurations, sometimes even register types of the extension to domain if it needed.

*Microsoft.Extensions.Configuration.IConfigurationSection
- added validators for some fields
- used default value from constant instead of literal
- fixed type of collection
- added contants with default values
- fixed typo in default constant
for json and for xml formats
- This allow extensions to be configured not only after domain is built
  but, if needed, during Upgrade process. Localization extension needs it.
- This source is alternative to XxxConfiguration.Load() call which is outdated.
- It also allow users to instanciate configurations and actually use them
  instead of forcefully configure them in config files. This gives a way to not rely
  on our Load methods or any other new "fancy" configuration APIs Microsoft "invents"
  (which sometimes broken for certain types of configuration sources :-)).
  Instance of configuration can be put to well-known collection instead of
  finding a work-around by looking at source code to figure out
  how to get configuration and where to put the instance of it to make
  extension work.
- For user convenience a set of extensions for DomainConfiguration provided
  to configure extensions from different resources, including configuration
  instance
- summaries for files, types, type members
- small code improvements
@alex-kulakov alex-kulakov merged commit 4444ada into 7.1 Oct 18, 2024
@alex-kulakov alex-kulakov deleted the 7.1-ioptions-config-loading branch October 18, 2024 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant