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.

}if (configMenu != null)AddMenuToolsPlugIns(configMenu);The configuration sett<strong>in</strong>gs—that is, the menu items to be added to the Tools menu—areread from the configuration file us<strong>in</strong>g the ConfigurationSett<strong>in</strong>gs class, as usual. Noth<strong>in</strong>g<strong>in</strong> the preced<strong>in</strong>g code reveals the presence of a custom section handler and acompletely custom <strong>XML</strong> schema <strong>for</strong> the sett<strong>in</strong>gs. The only fa<strong>in</strong>t clue is the use of aDataSet object.After it has been successfully loaded from the configuration file, the DataSet object ispassed to a helper rout<strong>in</strong>e, AddMenuToolsPlugIns, which will modify the menu. We'llreturn to this po<strong>in</strong>t <strong>in</strong> the section "Invok<strong>in</strong>g Plug-In Modules," on page 650; <strong>in</strong> themeantime, let's review the layout of the configuration file.The <strong>XML</strong> Layout of the Configuration Sett<strong>in</strong>gsThe data correspond<strong>in</strong>g to plug-<strong>in</strong> modules is stored <strong>in</strong> a section group namedTypicalW<strong>in</strong>FormsApp. The actual section is named PlugIns. Each plug-<strong>in</strong> module isidentified by an assembly name, a class name, and display text. The display textconstitutes the caption of the menu item, whereas the assembly name and the classname provide <strong>for</strong> a dynamic method call. As mentioned, <strong>in</strong> a realworld scenario, youmight <strong>for</strong>ce the class to implement a particular <strong>in</strong>terface so that it's clear to the call<strong>in</strong>gapplication which methods are available <strong>for</strong> the object it is <strong>in</strong>stantiat<strong>in</strong>g.Here is a sample configuration file <strong>for</strong> the application shown <strong>in</strong> Figure 15-2:Add new tool...MyToolsPlugInsMyPlugIn.AddNewToolSpecial tool...MyToolsPlugInsMyPlugIn.SpecialTool524

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

Saved successfully!

Ooh no, something went wrong!