Using WMFL implementation configurable Windows Forms
Author: Joe Stegman translation: Bischofia original source: http: //windowsforms.net/articles/wfml.aspx article formerly known as: Using the Windows Forms XML Parser Sample
Code download: download
Introduction
It is described here that an example with an expanded mechanism is implemented by adding a marker model. We can outline the parsing rules that "XML elements are mapped to the .NET Framework type and the properties in XML map to the type of properties, methods (or events)". This example contains a Markup Parser to dynamically generate an instance tree that generates an object by parsing the XML file. The formats for markers include the following structure:
1. XML namespace to the .NET Framework namespace mapping
2. Object instantiation name
3. Object verification and reference
4. Property setting
5. Examples and static methods
6. Event commission
7. Component reference
Disclaimer
The techniques used in this example are not part of the next version of Windows Forms. In addition, the example here is for the .NET Framework Version 1.1, as for other versions.
Basic Sample
The following example shows an XML syntax used to declare or define a simple form that contains Label.
XML Version = "1.0" encoding = "UTF-8"?>
Mapping XMLns = "http://www.microsoft.com/2003/windowsforms"
Namespace = "system.windows.forms; system.drawing"?>
XMLns: wfml = "http://www.microsoft.com/2003/wfml">
Form>
Wfml>
The WMFL parser dynamically generates a form based on the XML file above. Here, it assumes that the above XML file content is included in the "Basic.xml" file.
Markupparser Parser = New Markupparser ();
Object form = parser.parse ("Basic.xml");
Here is a dynamically generated form:
Dissecting The Basic Sample
According to the definition in the XML document, the parser performs accurate processing, a root label, entity declaration, and an end tag. The following is a description of each part.
XML Declaration
XML Version = "1.0" encoding = "UTF-8"?>
This line defines that XML defaults to the default namespace of this example simultaneously defines the prefixes of elements and properties.
Instance Declarations