Read custom configuration file in C# (Framework 4.0)

前端 未结 5 1705
执念已碎
执念已碎 2020-12-02 20:14

I am developing an application in C# under Framework 4.0.

In my application I would like to create separate configuration file that is not the app.config file. The c

5条回答
  •  借酒劲吻你
    2020-12-02 20:49

    My advice with configuration is create your own component to read it.
    It may ease the development if at some point you'll decide that you will be getting the configuration from another source like a database or over a web service.
    This kind of abstraction also helps you mock the configuration and increases testability (something that the .NET framework doesn't do well at all).
    If you are using XML as the configuration format I suggest using Linq to XML.
    It's easier to read and use to parse XML files.

提交回复
热议问题