A Response Configuration Change Notification:
The Configuration Application Block provides an event mechanism that notifies the application when the stored configuration changes, using the steps:
1) Create a Evernthandler
1/**////<summary>
2///Create Eventhanler
3///</summary>
4///<param name= "se NDEr "></param>
5///<param name=" args "></PARAM>
6 private void onconfigurationchanged ( object sender, Configurationchangedeventargs args)
7 {
8 Cursor = System.Windows.Forms.Cursors.WaitCursor;
9
Editorfontdata configdata = configurationmanager.getconfiguration ("Editorsettings") as EditorFontData;< br>
StringBuilder results = new StringBuilder (),
results. Append ("Configuration changes in storage were detected. Updating configuration. ");
Results. Append (Environment.NewLine);
Results. Append ("New Configuration settings:");
Results. Append (Environment.NewLine);
Results. Append (' t ');
Results. Append (Configdata.tostring ());
Results. Append (Environment.NewLine);
Cursor = System.Windows.Forms.CursoRs. Arrow;
}
2) Registration Event
1/**////注册事件
2 ConfigurationManager.ConfigurationChanged += new ConfigurationChangedEventHandler(OnConfigurationChanged);
Two To configure data caching:
Configuration Application Block provides a cache of configuration data at design time, reading the XML data, reading it again first determines whether the cache is empty, and if not, it reads the data directly from the cache (detailed in the profiling article).
Explicitly erase the cache with the following code:
1/**////清除缓存数据
2 ConfigurationManager.ClearSingletonSectionCache();
Three Extension mechanisms for senior staff:
1. In addition to using XML files to store data, you can also create your own storage methods, such as SQL Server Database, registry storage, and so on, we need to create our own storageprovider. To create a custom storage Provider, you need to be aware of the following points:
1 to read and write data, you need to inherit from the Storageprovider class and implement the Istorageproviderreader and Istorageproviderwriter interfaces separately:
1public class XmlFileStorageProvider : StorageProvider, IStorageProviderWriter
2 {
3 //……
4 }