{"id":19101925,"url":"https://github.com/existall/SimpleConfig","last_synced_at":"2025-04-18T19:31:23.277Z","repository":{"id":65413878,"uuid":"87477972","full_name":"existall/SimpleConfig","owner":"existall","description":null,"archived":false,"fork":false,"pushed_at":"2020-12-16T21:59:49.000Z","size":346,"stargazers_count":22,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-01T07:07:24.469Z","etag":null,"topics":["configuration","di-container","options","settings","simpleconfig"],"latest_commit_sha":null,"homepage":null,"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/existall.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-06T21:46:39.000Z","updated_at":"2021-02-07T20:22:49.000Z","dependencies_parsed_at":"2023-01-22T09:45:19.775Z","dependency_job_id":null,"html_url":"https://github.com/existall/SimpleConfig","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/existall%2FSimpleConfig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/existall%2FSimpleConfig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/existall%2FSimpleConfig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/existall%2FSimpleConfig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/existall","download_url":"https://codeload.github.com/existall/SimpleConfig/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223331091,"owners_count":17127913,"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":["configuration","di-container","options","settings","simpleconfig"],"created_at":"2024-11-09T03:53:32.394Z","updated_at":"2025-04-18T19:31:23.272Z","avatar_url":"https://github.com/existall.png","language":"C#","funding_links":[],"categories":["others"],"sub_categories":[],"readme":"\u003cimg src=\"https://raw.githubusercontent.com/existall/Shepherd/master/art/logo.png\" alt=\"ExistsForAll\"\u003e\r\n\r\nExistsForAll.SimpleSetting (previously SimpleConfig)\r\n=====================\r\n\r\n## Installation \r\n`Install-Package ExistForAll.SimpleSettings`\r\n\r\n## Table of Content\r\n1.Introduction  \r\n2.[Getting started](https://github.com/existall/SimpleConfig/blob/master/docs/getting_started.md)  \r\n3.[Building the collection](https://github.com/existall/SimpleConfig/blob/master/docs/building_the_collection.md)  \r\n4.[Building Config Interfaces](https://github.com/existall/SimpleConfig/blob/master/docs/Build%20Config%20Interface.md)  \r\n5.[DefaultValue](https://github.com/existall/SimpleConfig/blob/master/docs/Default%20Values.md)  \r\n6.[Build Section Binders](https://github.com/existall/SimpleConfig/blob/master/docs/Build%20a%20SectionBinder.md)  \r\n7.[Extending SimpleConfig](https://github.com/existall/SimpleConfig/blob/master/docs/Extend%20Simple%20Config.md)\r\n\r\nIntroduction - or why SimpleConfig was created\r\n----------------------------------------------\r\n\r\nWith the release of Asp.Net Core and .Net Core Microsoft has introduced `IOptions\u003c\u003e`.\r\nWhile `IOptions\u003c\u003e` is a great concept it lacks in implementation.\r\n`IOptions\u003c\u003e` provide a way to insert parameters into your app dynamically.\r\n\r\nFor example you have an email service that requires some URL to the email server.\r\n\r\n``` c#\r\npublic class EmailSender\r\n{\r\n    public EmailSender(string emailServiceUrl, ... )\r\n    {\r\n\r\n    }\r\n}\r\n```\r\n\r\nAll of the good IOC containers out there will tell you that injecting a string into a service is a bad idea.\r\nThe best of them won't let you do it.\r\n\r\n`IOptions\u003c\u003e` to the rescue, with `IOptions\u003c\u003e` you can request the option class that can provide the string you want provided from any data store you want (json file, database and so on).\r\n``` c#\r\npublic class EmailSender\r\n{\r\n    public EmailSender(IOption\u003cEmailProviderConfiguratation\u003e configuration, ... ) { }\r\n}\r\n```\r\nBUT `IOptions\u003c\u003e` is not the way to do this.\r\n\r\nWhy you ask ?\r\n\r\n1.  As Uncle Bob said, your application must be independent from frameworks this the application code takes an unnecessary dependency on a framework abstraction, this is a violation of DIP.\r\n2.  In order to inject `IOption\u003cSomeClass\u003e` `SomeClass` have to be a concrete class and not an interface.\r\n3.  To use `IOption\u003cSomeClass\u003e` you must call `services.Configure\u003cSomeClass\u003e` in the `Setup` class, this is not scale-able in any way and the last thing we want to do is to manually configure each configuration class.\r\n4.  Registering `IOption\u003c\u003e` in any other DI container different from Microsoft new DI container won't be a ball park.\r\n\r\nFor better understanding you can read this [explenation](http://https://simpleinjector.readthedocs.io/en/latest/aspnetintegration.html#working-with-ioption-t) from the SimpleInjecor docs.\r\n\r\n### TL;DR - or what SimpleConfig does?\r\n\r\nRemember the `IOption\u003cEmailProviderConfiguratation\u003e configuration`?\r\n\r\nwhat if we could build an interface like so\r\n``` c#\r\npublic interface IEmailServiceConfig\r\n{\r\n    [DefaultValue(\"SomeUrl\")]\r\n    string ServiceUrl {get; set;}\r\n}\r\n```\r\nand use it like so\r\n``` c#\r\npublic class EmailSender : IEmailSender\r\n{\r\n   public EmailSender(IEmailServiceConfig emailServiceConfig, ... ) { }\r\n\r\n   public void SendEmail(...)\r\n   {\r\n        Send(emailServiceConfig.ServiceUrl, ...);\r\n    }\r\n}\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexistall%2FSimpleConfig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexistall%2FSimpleConfig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexistall%2FSimpleConfig/lists"}