This sample project demonstrates how to create custom functions in the .NET engine and how to reference them so they can be utilized when generating output.
Custom Functions are referenced by tags in a Fluent Template and when the engine generates output, it will look to the custom function implementation defined in order to create an output value.
For this project, we have a template that references a custom function called CUSTOMFUNCTION() which will output a string specified by our custom function.
This project is setup where you only need to click the Start button and it should all work without any additional changes
- Open the project in Visual Studio
- Insert your license in the App.config file in the FluentCustomFunctionsTest project
- If you don't have a license you can leave it blank and a watermark will be present in output
- Set the function.files property in the App.config file in the FluentCustomFunctionsTest project to the path to the custom function dll (FluentCustomFunctions.dll)
- Set FluentCustomFunctionsTest as the startup project by right clicking on the FluentCustomFunctionsTest and selecting "Set as Startup Project".
- Run the sample (FluentCustomFunctionTest) with the Start button
To modify the custom function:
- Open the FluentCustomFunctions file in the FluentCustomFunctions project.
- Modify the returned value in the
public static string CUSTOMFUNCTION()method - Rebuild the FluentCustomFunctions project
- Run the sample (FluentCustomFunctionTest) with the Start button. You need to make sure FluentCustomTest is your start up project.
This section provides some more info about how this project is setup.
This solution contains 2 projects, FluentCustomFunctions which contains our custom functions implementation and another project FluentCustomFunctionsTest which generates a document using our custom function.
The FluentCustomFunctions project produces a dll to the FluentCustomFunctions/bin/Debug directory. This dll is then directly referenced by the FluentCustomFunctionsTest project.
Using the function.files property in the App.config file then tells the Fluent engine process to look for our custom functions implementation and use that during the document generation process.
More information about setting up the custom functions can be found in the More Information section below.
More information about how to use and setup custom functions with your application can be found here.