.NET Configuration Library for OpenSim - Supports INI, XML, Registry, and command-line configuration sources. Migrated to .NET 8 with modern collections and APIs.
$ dotnet add package AkiSim.NiniA powerful and flexible .NET configuration library supporting multiple configuration sources including INI files, XML, Windows Registry, command-line arguments, and environment variables.
Multiple Configuration Sources
Unified API: Access all configuration sources through a single, consistent interface
Type-Safe Access: Get configuration values as strings, integers, booleans, floats, doubles, and longs
Merge Support: Combine multiple configuration sources
Auto-Save: Automatically persist changes back to the configuration source
Event-Driven: Subscribe to configuration change events
dotnet add package Nini.Opensim
using Nini.Config;
// Load an INI file
IConfigSource source = new IniConfigSource("myconfig.ini");
// Access a configuration section
IConfig config = source.Configs["Database"];
// Get values with type conversion
string host = config.Get("host");
int port = config.GetInt("port", 3306); // with default value
bool enabled = config.GetBoolean("enabled");
IConfigSource source = new XmlConfigSource("myconfig.xml");
IConfig config = source.Configs["AppSettings"];
string value = config.Get("key");
// Parse: myapp.exe -host localhost -port 8080
IConfigSource source = new ArgvConfigSource(args);
source.AddSwitch("Settings", "host", "h");
source.AddSwitch("Settings", "port", "p");
IConfig config = source.Configs["Settings"];
string host = config.Get("host");
int port = config.GetInt("port");
// Load default configuration
IConfigSource defaults = new IniConfigSource("defaults.ini");
// Override with user configuration
IConfigSource userConfig = new IniConfigSource("user.ini");
defaults.Merge(userConfig);
// Values from userConfig override defaults
IConfig config = defaults.Configs["Settings"];IConfigSource source = new IniConfigSource("config.ini");
source.AutoSave = true;
IConfig config = source.Configs["Settings"];
config.Set("lastRun", DateTime.Now.ToString());
// Automatically saved to config.ini[Database]
host = localhost
port = 3306
username = admin
enabled = true
[Logging]
level = Info
path = /var/log/app.log<configuration>
<configSections>
<section name="Database" type="System.Configuration.NameValueSectionHandler" />
</configSections>
<Database>
<add key="host" value="localhost" />
<add key="port" value="3306" />
</Database>
</configuration>[SupportedOSPlatform("windows")])Version 2.0.0 introduces breaking changes:
Dictionary<T,K> and List<T> instead of legacy Hashtable and ArrayListIf you're upgrading from version 1.x, your existing code should work with minimal changes. The public API remains largely compatible.
For complete documentation and advanced usage examples, visit:
This version is specifically maintained for the OpenSim virtual world simulator. It includes optimizations and updates tailored for OpenSim's configuration needs.
MIT License - See LICENSE file for details
Contributions are welcome! Please submit pull requests to the GitHub repository.