Monday, 19 November 2007

Chapter 9, Lesson 4: Configuration Management.

... e.g. specifying what vers of runtime app needs, or telling app what db to connect to.

Getting/Storing settings
  • ConfigurationManager class - retrieves config settings.
  • ConfigurationManager.appSettings - exposes AppSettings.
  • ConfigurationManager.ConnectionStrings - exposes conn strings
  • ConfigurationManager.GetSection(\
    ) - rets Object.
  • ConfigurationManager.Save/SaveAs - provided... 1) ConfigurationSection.SectionInformation.ForceSave = true; 2) filename: AppName.exe.config.

Implementing Config Interfaces

  • ConfigurationSection class - replaces the deprecated IConfigurationSectionHandler interface.
  • 1) Create section in config file - decl + impl outside of all other config elts, 2) retrieve section programatic\lly - ConfigurationSectionGroupCollection gps = config.SectionGroups;
  • how to handle section? create class that impl IConfigurationSectionHandler, and impl. Create() mthd. The retrieve using ConfigurationManager.GetSection, as above.

.NF 2.0 mthd, without impl config int - r/w directly from custom config section.

  • 1) Create section in config file - decl + impl as above, 2) use ConfigurationClass as base class from which to derive classes to consume these values.

No comments: