13.07.2015 Views

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

scratch or <strong>in</strong>herit from an exist<strong>in</strong>g class. The section handler object is responsible <strong>for</strong>read<strong>in</strong>g and pars<strong>in</strong>g the actual contents of the sett<strong>in</strong>g.Declar<strong>in</strong>g a New SectionThe node conta<strong>in</strong>s the declarations of all the sections <strong>in</strong> the variousconfiguration files. The predef<strong>in</strong>ed sections are declared <strong>in</strong> the mach<strong>in</strong>e.config file thatthe .<strong>NET</strong> Framework <strong>in</strong>stalls. Custom sections must be registered by the applicationthat plans to use them. The application's configuration file is a good place <strong>for</strong> <strong>in</strong>sert<strong>in</strong>gthis <strong>in</strong><strong>for</strong>mation.The node can accept up to four child nodes: ,, , and . The element removes a previouslydef<strong>in</strong>ed section, or a section group, from the block. The element clears all previously def<strong>in</strong>ed sections and section groups.NoteThe and elements don't affect the actual datastored <strong>in</strong> the configuration file. Remov<strong>in</strong>g a section doesn't erasethe related data from the file, but the data becomes unreachablebecause of the miss<strong>in</strong>g section declaration.A new section is registered us<strong>in</strong>g the element. As mentioned, the nameattribute of this element specifies the name of the section and the type attributespecifies the name of the section handler class. The name of the configuration sectionclass should conta<strong>in</strong> full assembly <strong>in</strong><strong>for</strong>mation, <strong>in</strong>clud<strong>in</strong>g version, culture, and public keytoken, if any. All the predef<strong>in</strong>ed handlers are def<strong>in</strong>ed <strong>in</strong> the same assembly andthere<strong>for</strong>e share the same <strong>in</strong><strong>for</strong>mation, as <strong>in</strong> the follow<strong>in</strong>g example:System, Version=1.0.3300.0, Culture=neutral,PublicKeyToken=b77a5c561934e089NoteWhen you create a custom assembly with no strong name (a strongname is necessary if you want to put the assembly <strong>in</strong> the globalassembly cache), the version number is def<strong>in</strong>ed <strong>in</strong> the assembly<strong>in</strong>fofile that <strong>Microsoft</strong> Visual Studio .<strong>NET</strong> automatically adds to theproject. The culture is neutral, and the public key token is null.Here's an example:AppSett<strong>in</strong>gs_CS, Version=1.0.9.0, Culture=neutral,PublicKeyToken=nullThe custom section follows the block and conta<strong>in</strong>s the actualconfiguration sett<strong>in</strong>gs. The follow<strong>in</strong>g code creates a new section nameduserPreferences that accepts name/value pairs:516

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!