UnifiedConfig
UnifiedConfig copied to clipboard
A common configuration utility which operates xml and ini as well as json. It enable you to invoke unified method for different config files.
UnifiedConfig
A common C# class to manipulate xml, ini and json config files with unified interfaces.
Features
- 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.
Usage
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.
Roadmap
Issues and PRs are welcomed.
- [X] Support for json
- [X] Nuget package
- [X] Auto-inference the type of config file without extension detection
- [X] Support returning more types other than string (via ToObject<T> method)
- [X] Support of IEnumerable for sophisticated query
- [ ] ~~Support for int indexer~~ is removed since the xpath supported already
- [ ] Ready to go template project
- [X] Case-sensitive swtich for path matching
- [X] Return null other than throwing error if xpath not exist
Update Notes
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.