Extensions
You can add additional functionality to Concordion.NET with the help of extensions. For example additional commands, event listeners, or output modifiers can be introduced based on Concordion.NET extensions.
Extensions API
A dedicated section of the executable specifications describe the extensions API of Concordion.NET. The fixture classes demonstrate how to use the extensions API.
See also the extensions of the Java version of Concordion for examples what can be achived with the help of the extensions API.
Adding extensions to Concordion.NET
Extensions are added to Concordion.NET by:
- Annotating the fixture class with
[Extensions]
. This annotation is parameterized with a list of extension, and/or extension factory, classes to be installed. For example:[Extensions(typeof(LoggingTooltipExtension.class), typeof(TimestampFormatExtension.class))] public class MyTest { ...
- Or annotating public fields in the fixture class with
[Extension]
. This allows the extensions to be configured per class instance. For example:... [Extension] public ConcordionExtension extension = new ScreenshotExtension().setScreenshotTaker(camera); ...
- Or by adding configuration entries
<Extension>
in the section<ConcordionExtensions>
of the configuration file. For example:<ConcordionExtensions> <Extension assembly="LoggingTooltipExtension" type="Ext.LoggingTooltipExtension" /> </ConcordionExtensions>
For further details see the extension configuration specification.
Building your own extension
Extensions must implement the ConcordionExtension interface, which allows extensions to hook into the Concordion.NET processing through the ConcordionExtender interface.
Example: Adding custom CSS
Amongst other features, the ConcordionExtender
interface provide a means for adding CSS, JavaScript or arbitrary resources to the Concordion.NET output folder.
The following example extension copies /my_concordion.css
from the classpath to the root folder of the Concordion.NET output, and links to it from the Concordion.NET output HTML.
using org.concordion.api.extension; namespace Com.Acme { public class MyCssExtension : ConcordionExtension { public void addTo(ConcordionExtender concordionExtender) { concordionExtender.withLinkedCSS("/my_concordion.css", new Resource("/my_concordion.css")); } } }
Note: if you have already declared a link to the CSS file in your HTML, you should use concordionExtender.withResource()
rather than concordionExtender.withLinkedCSS()
to avoid a duplicate declaration.
If you'd prefer to embed the CSS in the HTML, use concordionExtender.withEmbeddedCSS()
. Similar methods exist for including JavaScript in the output, or you can use
withResource()
to copy images or other resources to the output.