开发者

Typed configuration data in a separate config file in ASP.Net 4.0?

  1. I have an asp.net 4.0 web application.
  2. I need extensive configur开发者_如何转开发ation data for this web application, that is strongly typed and the structure of this configuration data is going to be fairly complex (cannot do with key-value pairs). In the past I remember having done this in .Net 2.0 but cannot figure out how I will do it in .Net 4.0. The class and config mapping is like shown below (really simplified for the purpose of illustration only):

     class SettingsClass
     {
      int count;
      string name;
      decimal amount;
     }
    
     <SettingsClass>
      <count>2</count>
      <name>Moiz</name>
      <decimal>10.66</decimal>
     </SettingsClass>
    
    1. I need this configuration in a separate file (other than the web.config).
    2. I don't think I would have to write explicit serialization/deserialization code.

Does .Net 4.0 configuration classes provide this kind of built in facility?

Would I need to use Enterprise Library 5.0 to get this done?


You can introduce strongly typed sections in configuration files with custom configuration handlers.

If you need these configurations in a separate file you can use OpenMappedExeConfiguration to load additional configuration files.

You can use both practices in .NET 2.0 and 4.0.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜