Skip to content

add read-only option to ConfigurationBuilder #154

@fafa3711

Description

@fafa3711

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions