开发者

Should I use XML to store configuration settings in my C#.Net application?

My question relates to the performance implications of reading application configuration data from an XML file.

I am building an application that lists information from a database and needs to know how to display the lists, depending on the types of data returned.

This is difficult to explain, but basically I would like to have an XML config file that lists the types and describes how to display them. This will allow me to change the display methods without re-compiling the application.

My question is really around performance. Given that my application will need to use this data many times during each page load...

  • Should I be reading directly from the XML file and parse it each time I need it?
  • Or should I cache the XML object and parse it each time I need it?
  • Or should I parse the XML once, generate some sort of object and cache that object?

My gue开发者_运维技巧ss is option 3, but I'm basically fishing for best practice around this.

Thanks.


There is already a convention for this, called the App.config file.

It is XML, and Visual Studio has tooling support for it.

My suggestion is: Don't reinvent the wheel, if you can help it.


Now, given that your format is too complex for that, you probably want to go with option 3, but load it lazily.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜