开发者

What is a good configuration file tool for C#

I'm writing a new C# application which will make heavy use of a configuration file. My requirements are:

  1. Human readable
  2. Name value pairs
  3. Hierarchical
  4. [Updatable by application]

Um, to transla开发者_运维技巧te: I want to define an object and a set of configuration parameters associated with that object. The configuration parameters may be name value pairs or another object, with it's own attributes attached:

module "db" { host: "db.example.com"; encoder "zip" { compression: 10; } }

I'm less committed to requirement 4, but do consider that I would like the application to update a setting and write it back to the configuration file.

I am aware of the following options:

  1. XML. Not sufficiently human readable.
  2. INI file. Not hierarchal
  3. JSON.
  4. YAML.

JSON and YAML seem worth investigating.

Advise on using these for configuration? Any alternate tools I may want to consider?

As for persisting changes made by the application back to the config file I know that JSON and YAML can do this but can either do this WHILE saving comments which may have been in the original human edited version?


No sense in rebuilding the wheel. Why not just use the built-in configuration API? It uses XML, so you can edit by hand at run-time if you want to. there is a built-in editor in the IDE to edit at build-time.

here is more from MSDN


I use custom configuration files when I need to do something like that. Here's how I did it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜