Last time we looked at the XSD file and a sample rendering from XML to C#. This time I’ll introduce the primary interfaces used in the rendering process.
First we have an ITask.
public interface ITask
An ITask contains a Namespace, Class and BaseClass as well as a collection of ITaskProperty items (which we’ll see next). These map directly to the Namespace, Class and BaseClass attributes of the Task element in the XSD.
Next we have ITaskProperty
public interface ITaskProperty
An ITaskProperty, like an ITask, is a mirroring of the XSD attributes. I’ll assume this is all quite clear – otherwise leave a comment.
Finally we have the rendering engine – an ITaskGenerator.
public interface ITaskGenerator
void Generate(ITask tf, TextWriter outStream);
Pretty straight forward.
The last thing for today is the loading of the input XML. Since we have an XSD we can use xsd.exe to generate a class for XML serialization. This generated 3 classes and an enum.
The classes are Tasks, TasksTask, and TasksTaskProperty.
The enum is PropertyType.
I encourage you to copy the XSD file into a file named “GenTask.xsd” and run:
xsd.exe /c GenTask.xsd
Tomorrow: Implementing the ITask interface,