A common C# class to manipulate xml, ini and json config files with unified interfaces.
- Wrapped the difference among xml, ini and json, you can access the config file without the consideration of format.
- Provide XPath as default locating method.
- Saving file will not change the original format.
Recommend nuget package
Install-Package UnifiedConfig
OR
- compile the class library and add reference of the dlls including the "UnifiedConfig.dll" to your project.
- add using statement to your namespaces.
- you can call the functions by using the following code or just read the test class.
ConfigManager config = new ConfigManager("test.ini");
Assert.Equal("5", config[@"//Default/Interval"]);
alternatively, you can directly start a project from the solution. By adding a new project into the solution, you can easily make use of the class. A unittest project is provided.
Issues and PRs are welcomed.
- Support for json
- Nuget package
- Auto-inference the type of config file without extension detection
- Support returning more types other than string (via ToObject method)
- Support of IEnumerable for sophisticated query
-
Support for int indexeris removed since the xpath supported already - Ready to go template project
- Case-sensitive swtich for path matching
- Return null other than throwing error if xpath not exist
UPDATE 2020/06/05: Return null if xpath not exists.
UPDATE 2017/07/29: Add Case-sensitive swtich for path matching
UPDATE 2017/07/25: Add Name property and fix the IEnumerable bug.
UPDATE 2017/07/24: Add IEnumerable support for sophisticated query.
UPDATE 2017/07/22: Add Auto-inference and type conversion.
UPDATE 2017/07/20: Add json support.
UPDATE 2017/07/18: Nuget package supported.