Thursday, July 3, 2008

Configuration Section Manager

OverView
  • The IConfigurationSectionHandler interface provides a mechanism to access customized sections of a configuration file.

  • The Create method is the only implementation detail necessary to fulfill the IConfigurationSectionHandler contract.

  • To be used safely, all classes that implement IConfigurationSectionHandler must be both thread safe and stateless.

  • The ConfigSections node of the configuration file is the main mechanism provided for implementing custom sections.

  • ConfigurationSection objects can be used to programmatically add configuration sections, as opposed to manually entering them through the configuration file.

  • To save any changes made to a Configuration object, use the Save method.

  • If an alternate file is to be used for changes to a Configuration object, SaveAs facilitates this.

  • The ApplicationSettingsBase class serves as wrapper to implement configurable application settings in .NET applications.

  • All settings stored by an ApplicationSettingsBase class use the LocalFileSettingsProvider for storage.


You can use the following questions to test your knowledge of the information in Lesson 4, "Configuration Management." The questions are also available on the companion CD if you prefer to review them in electronic form.


Answers

Answers to these questions and explanations of why each answer choice is right or wrong are located in the "Answers" section at the end of the book.

1.

Which methods of the Configuration class are valid ways to open a configuration file? (Choose all that apply.)

  1. OpenExeConfiguration

  2. OpenMachineConfiguration

  3. OpenMappedExeConfiguration

  4. OpenMappedMachineConfiguration

Image from book

2.

What method causes settings to be read from an IConfigurationSectionHandler object?

  1. Create

  2. ReadSection

  3. GetConfig

  4. GetAppSettings

Image from book

Answers

1.

Correct Answers: A, B, C, and D

  1. Correct: OpenExeConfiguration is a valid method to open a configuration file.

  2. Correct: OpenMachineConfiguration is a valid method to open the machine configuration file.

  3. Correct: OpenMappedExeConfiguration is a valid method to open a configuration file as long as a mapping is specified.

  4. Correct: OpenMappedMachineConfiguration is a valid method to open the machine configuration file.

2.

Correct Answer: A

  1. Correct: Create is the only method in the IConfigurationSectionHandler interface that needs to be implemented.

  2. Incorrect: ReadSection is not a valid method of the IConfigurationSectionHandler interface.

  3. Incorrect: GetConfig is not applicable in this setting.

  4. Incorrect: GetAppSettings is not applicable in this setting.

No comments: