send2vinnie / AppCfg.Net

Type-safe, easy and power configuration framework for .NET developers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AppCfg.Net Build status

Type-safe, easy and power configuration framework for .NET developers

Installation

Install-Package AppCfg.Net

Demo

https://github.com/minhhungit/AppCfg.Net/blob/master/AppCfgDemo/Program.cs

First look

<appSettings>
  <add key="Age" value="29"/>
  <add key="user-name" value="Hung Vo"/>
</appSettings>

public interface ISetting
{
    int Age { get; }
	
    [Option(Alias = "user-name")] 
    string Username { get; }
}

var settings = MyAppCfg.Get<ISetting>()

var age = settings.Age;
var username = settings.Username;

Did you notice? Settings are read-only!

Supported Types

AppCfg.Net is also support nested setting

Supported Setting Store

  • AppSetting [ Demo ]
  • Custom stores like MSSQL database, Redis, Text file... it's up to you. [ Demo ]

With Custom stores, it also support multi-tenancy!

Custom Type Parser

In case you need a type parser which was not supported, even if you don't like existed parser, you can create one for yourself and register it, or create a request for me, I will try to help!

  • The simplest way to create a custom parser is implementing parser from interface ITypeParser, see example. Default setting source is appSetting
  • If you want to change setting source, like you want to get setting from a json file, or even from table in database, you should implement your parser from interface ITypeParserRawBuilder, demo is here

After you created a parser, you must register it, for example:

MyAppCfg.TypeParsers.Register(new DemoParserWithRawBuilder());


Donate ^^

If you like my works and would like to support then you can buy me a coffee ☕️ anytime

Buy Me a Coffee at ko-fi.com

I would appreciate it!!!

About

Type-safe, easy and power configuration framework for .NET developers

License:MIT License


Languages

Language:C# 96.2%Language:TSQL 3.8%