About .NET Conversion Scripts
With CES 7, you can now also create C# preconversion or postconversion scripts. You can select the DLL or the .cs file, in which case, CES automatically compiles the file on-demand. Furthermore, when you update the source file, CES automatically uses the updated file so you do not need to explicitly reload the .NET script file from the Administration Tool (see Adding a Preconversion Script and Adding a Postconversion Script).
Note: When using .NET source code rather than the compiled DLL, you must explicitly declare the optional parameters.
You can debug your .NET scripts with Visual Studio. Simply attach to the CESConverter7.exe process and put breakpoints in your code.
The signature of the methods that you can use for preconversion, postconversion or custom converter scripts are:
public override void RunPreConverter(COMCoveoConverters.PreConversion p_PreConversion, COMCoveoConverters.DocumentInfo p_DocumentInfo)
{
}
public override void RunPostConverter(COMCoveoConverters.PostConversion p_PostConversion, COMCoveoConverters.DocumentInfo p_DocumentInfo)
{
}
public override void RunCustomConverter(COMCoveoConverters.CustomConversion p_CustomConversion, COMCoveoConverters.DocumentInfo p_DocumentInfo)
{
}
The converter base class is Coveo.CES.DotNetConverterLoader.dll. You also need to reference the Coveo.CES.Interops.dll assembly to get the COMCoveoConverters.XXX object definitions. Both files are available in the [CES_Path]\Bin\ folder.
Important: In Visual Studio, do not worry that IntelliSense is not able to detect classes from the using declarations. When you will configure your script file (.css or .DLL) as a CES preconversion or postconversion script, it will work.
Sample C# Custom Converter
The following code is a sample of a C# custom converter.
using Coveo.CES.DotNetConverterLoader;
using Coveo.CES.Interops.COMCoveoConvertersWrappers;
namespace TestDotNetConverter
{
public class MyCustomConverter : CustomConverter
{
public override void RunPreConverter(PreConversion p_PreConversion, DocumentInfo p_DocumentInfo)
{
p_PreConversion.Trace("Hello, world!", SeverityEnumeration.SeverityNormal);
}
public override void RunPostConverter(PostConversion p_PostConversion, DocumentInfo p_DocumentInfo)
{
p_PostConversion.Trace("Hello, world!", SeverityEnumeration.SeverityNormal);
}
public override void RunCustomConverter(CustomConversion p_CustomConversion, DocumentInfo p_DocumentInfo)
{
p_CustomConversion.Trace("Hello, world!", SeverityEnumeration.SeverityNormal);
}
}
}
The .NET custom converters must inherit from the CustomConverter class, and implement a method named RunPostConverter that takes as arguments the objects that would normally be available as global variables in VBS scripts.