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

add read-only option to ConfigurationBuilder #154

Open
fafa3711 opened this issue Jul 10, 2023 · 0 comments
Open

add read-only option to ConfigurationBuilder #154

fafa3711 opened this issue Jul 10, 2023 · 0 comments

Comments

@fafa3711
Copy link

It would be handy to be able to specify if a built config is read-only, even though the underlying store is read-write.
Background: I'm using Config.Net with JSON files to provide configuration for a library that needs a good number of static configured values. Of course I can just not provide a set accessor, but that is not what I'm after. I use Autofac DI to inject configurations into the various parts of the application and it works great, by registering the interface with a lambda in Autofac:

builder.Register(c =>
        {
            var configBuilder = new ConfigurationBuilder<ICoreConfig>();
            configBuilder.UseJsonFile(Path.Combine(path, "CoreConfig.json"));
            return configBuilder.Build();
        }).SingleInstance();

For command line utilities, I would like to selectively change (set) parts of the ICoreConfig, but not write out the changed config back to JSON. Right now, if I modify any values, they are persisted back to the original store.

I'd be happy to do this myself and file a PR if this something to fit into the concept of the library, but would probably have some feedback on the best way to go about it.

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

No branches or pull requests

1 participant