{"id":21559795,"url":"https://github.com/dasiths/nimbleconfig","last_synced_at":"2025-07-11T18:08:19.900Z","repository":{"id":115865666,"uuid":"141587937","full_name":"dasiths/NimbleConfig","owner":"dasiths","description":"A simple, unambitious, convention-based configuration injector for .NET with full support for Aspnetcore","archived":false,"fork":false,"pushed_at":"2020-06-18T02:29:56.000Z","size":115,"stargazers_count":9,"open_issues_count":1,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-09T06:36:58.140Z","etag":null,"topics":["appsettings","aspnetcore","configuration-management","netcore"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dasiths.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-19T14:02:22.000Z","updated_at":"2023-07-11T00:15:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"e371c6ce-8f07-4d21-9963-26ad4cb095dd","html_url":"https://github.com/dasiths/NimbleConfig","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dasiths%2FNimbleConfig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dasiths%2FNimbleConfig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dasiths%2FNimbleConfig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dasiths%2FNimbleConfig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dasiths","download_url":"https://codeload.github.com/dasiths/NimbleConfig/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248211139,"owners_count":21065677,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["appsettings","aspnetcore","configuration-management","netcore"],"created_at":"2024-11-24T09:09:29.103Z","updated_at":"2025-04-10T11:41:37.284Z","avatar_url":"https://github.com/dasiths.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NimbleConfig [![Build status](https://ci.appveyor.com/api/projects/status/4wbdssddl5qxukk7?svg=true)](https://ci.appveyor.com/project/dasiths/nimbleconfig) [![NuGet](https://img.shields.io/nuget/v/NimbleConfig.DependencyInjection.Aspnetcore.svg)](https://www.nuget.org/packages/NimbleConfig.DependencyInjection.Aspnetcore) [![Downloads](https://img.shields.io/nuget/dt/NimbleConfig.DependencyInjection.Aspnetcore.svg)](https://www.nuget.org/packages/NimbleConfig.DependencyInjection.Aspnetcore/)\n\n### A simple, unambitious, convention-based configuration injector for .NET using IConfiguration (`Microsoft.Extensions.Configuration`) with full support for AspNetCore.\n  \n---\n\n## Getting Started\n\n1. Install and reference the Nuget `NimbleConfig.DependencyInjection.Aspnetcore`\n\nIn the NuGet Package Manager Console, type:\n\n```\n    Install-Package NimbleConfig.DependencyInjection.Aspnetcore\n```\n\n2. Define your settings class as follows\n```C#\n    // Our setting is a string\n    public class SomeSetting: ConfigurationSetting\u003cstring\u003e\n    {\n    }\n\t\n    // or for a more complex type\n\t\n    public class SomeComplexSetting : IComplexConfigurationSetting\n    {\n        public string SomeProperty { get; set; }\n    }\n```\n3. Add it to your `appsettings.json`\n```C#\n    {\n        \"SomeSetting\": \"SomeValue\",\n        \"SomeComplexSetting\": {\n            \"SomeProperty\": \"SomeValue\"\n        }\n    }\n```\n4. Inject and use it in your controllers, services etc\n```C#\n    public class ValuesController : ControllerBase\n    {\n        private readonly SomeSetting _someSetting;\n        private readonly SomeComplexSetting _someComplexSetting;\n\t\t\n        public ValuesController(SomeSetting someSetting, SomeComplexSetting someComplexSetting)\n        {\n            _someSetting = someSetting;\n            _someComplexSetting = someComplexSetting;\n        }\n\t\t\n        public ActionResult\u003cIEnumerable\u003cstring\u003e\u003e Get()\n        {\n            return new string[] { \n                _someSetting.Value,\n                _someComplexSetting.SomeProperty\n            };\n        }\n    }\n```\n5. In the `ConfigureServices()` method in your `Startup.cs` add the following to scan and inject settings types\n```C#\n    public void ConfigureServices(IServiceCollection services)\n    {\n        // Other services go here\n\t\t\n        // Wire it up using the fluent api\n        services.AddConfigurationSettings().AndBuild();\n    }\n```\n---\nYou can try this if you have to __access some configuration setting prior to setting up the DI__ container. (Be warned! This will create a instance of a factory for each call. Only do this if there is no other way.)\n\n```C#\n    // You still need to provide an instance of IConfiguration\n    var dirtySetting = configuration.QuickReadSetting\u003cSomeSetting\u003e();\n```\n\n## Want more?\n\n#### See the sample projects for more advanced use cases like complex types, enums and arrays. Checkout the `ConsoleApp` example on how to use it in a non aspnetcore app. \n\nNimbleConfig provides **full customisation** of the setting creation via **lifetime hooks** in `IConfigurationOptions`. This is done via creating your own resolvers for the name (`IKeyName`), reader (`IConfigurationReader`), parser (`IParser`), constructor (`IValueConstructor`).\n\n__Example of setting a prefix uisng the configuration options lifetime hooks__\n```C#\n\n    var configOptions = ConfigurationOptions.Create()\n                            .WithGlobalPrefix(\"MyAppSettings:\") // Adding a global prefix to key names\n                            .WithNamingScheme((type, name) =\u003e // Resolving type specific key names\n                            {\n                                if (type == typeof(SomeSetting)) // selectively apply logic\n                                {\n                                    return new KeyName(\"AnotherPrefix\", name.QualifiedKeyName);\n                                }\n                         \n                                return name; // return the auto-resolved one if no change is needed\n                            });\n    \n    // Then just pass it in to the builder uisng the fluent api\n\t\n    services.AddConfigurationSettings()\n            .UsingOptionsIn(configOptions)\n            .AndBuild();\n```\n\t\t\t\t\t\t \n**These fluent apis allow you to easily add your custom logic.** They take a function which accepts a type and the auto-resolved instance as seen in the above example.\n \n- `.WithNamingScheme()` for setting configuration key names.\n- `.WithReader()` for setting a custom config reader.\n- `.WithParser()` for setting a custom parser.\n- `.WithConstructor()` for setting a custom value constructor.\n\n---\n\nFeel free to contribute and raise issues as you see fit :)\n\n- Creator: Dasith Wijesiriwardena (http://dasith.me)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdasiths%2Fnimbleconfig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdasiths%2Fnimbleconfig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdasiths%2Fnimbleconfig/lists"}