Writing ZPT-Sharp plugins
At present, ZPT-Sharp may be extended with two types of plugins. These are installed via the application configuration file.
-
TALES expression evaluators, which facilitate the handling of expressions,
such as
string:Hello World!
orcsharp:DateTime.Now.AddDays(5)
. - ZPT document providers, which facilitate the rendering of specific document implementations such as HTML or XML.
In the following guidance, links are provided to the API documentation for the types which are referenced. This will provide a more in-depth discussion of interface members which must be implemented and the functionality provided by base types.
Writing expression evaluators
TALES
expression evaluator plugins are types which implement
CSF.Zpt.Tales.IExpressionEvaluator
;
this interface is found in the CSF.Zpt.Abstractions.dll assembly.
All such plugin types must provide a parameterless public constructor, the ZPT core logic requires
it.
You may also find it useful to derive your plugin from the abstract base type
CSF.Zpt.Tales.ExpressionEvaluatorBase
;
this class is found in the CSF.Zpt.dll assembly.
Writing document providers
ZPT document provider plugins require the creation of a number of types to be fully functional. The following list illustrates the minimum requirement to create a working plugin. In this list, all interfaces are found in the CSF.Zpt.Abstractions.dll assembly, and all classes (abstract or otherwise) in the CSF.Zpt.dll assembly:
-
A document type which implements
CSF.Zpt.IZptDocument
. It is recommended to derive from the base classCSF.Zpt.ZptDocument
. -
An element type which implements
CSF.Zpt.Rendering.IZptElement
. You may find it useful to derive fromCSF.Zpt.Rendering.ZptElement
. -
An attribute type which implements
CSF.Zpt.Rendering.IZptAttribute
. -
The document provider type which implements
CSF.Zpt.IDocumentProvider
. The document provider type must provide a public parameterless constructor, the ZPT core logic requires it.
The document provider type serves as the entry-point to your plugin. It is the type which you must reference in the configuration file if you wish to make your plugin the default HTML or XML provider.
In essence, these types relate to one another as follows: The document provider is responsible for creating instances of your document type when required for a rendering operation. The document type is responsible for creating instances of your element type and in turn that element type is responsible for creating instances of the attribute type.