This configuration library is intended to give .NET Developers a simple, extendable, scaleable, fast, type safe possibility to configure all kind of .NET applications.
- Type safe
- Easy to use
- Multiple configuration language
- Separate operations and development
- Easy detection of missconfiguration
- Easy API
- Multiple applications
- Multiple systems
- Change and reload configuration on the fly
- Easy access to database connections
If autoreload is enabled, every change to a configuration value is automatically recognized by DslConfig. The changed configuration values can be used directly without restarting your application.
- Just install DslConfig per NuGet
- Add a folder named config to your project
- Add a file Variables.var to the config folder and ensure this file gets copied to the output folder
- Start adding and using config values in C# or Boo language
The config files get compiled, thus configuration errors are show immedatily with a proven error message format. The config values are real .NET types. Parsing of config values belongs to the past. Use the power of the C# and Boo compiler to your advantage.
Get your configuration values in less than 0.5 ms.
Start with a single application on a developer host and scale up your solution to multiple applications on multiple hosts with a single configuration solution. DslConfig grows with your solution as needed.
Easy to use
Accessing a configuration value is really easy.
var timeout = config.GetVariable<TimeSpan>("ConnectionTimeout");
Multiple configuration language
Just decide if you like C# or Boo as configuration language and write your configuration files (e.g. Variables.var) in C# or Boo syntax.
Example for C# Configuration
DslConfig.IConfiguration config = new DslConfig.CSharp.Configuration();
Example for Boo Configuration
DslConfig.IConfiguration config = new DslConfig.Base.Configuration();
Separate operations and development
Operations typically needs host or service specific configuration values which resides in the *.host or *.boo files of DslConfig
Developers typically needs configurable values (Variables.var) or service specific configuration values which resides in the *.var or *.boo files of DslConfig
I recommend putting all configuration values for operations in the *.host files and all configuration values for developers in all others files.
Easy detection of missconfiguration
The configuration files get compiled and therefore the compiler detects misconfigurations. Thus compilers are really a robust, very well tested and very well known peace of software, there is no better mechanism to check your configuration files for errors. Compiler error message are very specific. In most of the cases they tell you the line and column of the error in conjunction with a really good error message.
In 99% of the time you will need
To get the current service (application) use
To get the host use
To reload your configuration (e.g. if autorelad is disabled)
DslConfig uses the common.logging framework. Thus you can use NLog, log4net or any other logging framework you like. If logging is enabled DslConfig logs useful things like the configuration directory used and the configuration files are used. This really useful in complex enviornments and on application setup.
DslConfig files can be structured in a hierarchical way to keep maintenance of config files simple, regardless of the size of your software solution.
If your software solution consits of multiple applications, windows services, web applications, then DslConfig supports you to keep configuration of all that solutions in a central place. DslConfig supports config files for every single application or a single config file for all application.
Multiple systems could be developer workstations, development systems, integration systems, staging systems, produciton systems and systems for specifc customers. If you have multiple systems, then DslConfig does support you to configure the different applications on those systems.
Change and reload configuration on the fly
DslConfig files are simple text files.
You can edit the config files directly in your application (for example show the config files in a textarea of your web application) and reload the config files per
You can show any compiler errors to the user to be sure that the config files are valid.
Easy access to database connections
The *.host files of DslConfig does support you on common host depend tasks. In DslConfig there is a special syntax for configuring database connections and email services.
To configure and use a database connection use
DbConnections["DB1"] = new SqlConnection("Data Source=(localhost\\SQLExpress);Initial Catalog=DB1");
in your config file. You can access this connection in your code via
Try http://www.connectionstrings.com/ to build your connection strings and see other data provider than sql server (SqlConnection) like System.Data.OracleClient.OracleConnection, MySql.Data.MySqlClient.MySqlConnection, ...
To configure and use a email service use
SmtpClient.Port = 25
SmtpClient.Host = "mymailhost.com"
in your configuraiton file. In your application use
to send a email.
For further details see https://github.com/johannes-brunner/DslConfig/wiki