This example shows you how to create a sample C# library and adapt it to a MapForce Function File (.mff) that can be imported as a MapForce library.
|Note:||Adapting a C# library to .mff format is just one of the ways to import C# libraries in MapForce. A simpler alternative is to import .NET assemblies directly, see Example: Import Custom .NET DLL Assembly.|
The configuration process consists of the following steps:
1.Create a new class library project in Visual Studio. Notice that the function has been defined as public static.
2.If you need special XML Schema types (such as date and duration), add a reference from your Visual Studio project to the Altova.dll library. To obtain this library, generate C# code from a mapping without custom functions. The Altova.dll file will be located in the ..\Altova\bin\debug directory relative to the directory where the code was generated. To add the reference to Altova.dll in Visual Studio, on the Project menu, click Add Reference and browse for the Altova.dll file. Also, add to your code the following line: using Altova.Types; . For information about how XML Schema types map to C# types, see Data Type Mapping.
3.Build your Visual Studio project. The MyLibrary.dll is generated in your project output directory.
4.Using an XML editor, create a new .mff file and validate it against the ..\Program Files\MapForceLibraries\mff.xsd schema. Make sure that all references under implementation language="cs" point to the correct C# members and paths created previously. Also, the line function name="SayHello" must refer to the function name exactly as it was defined in C#, see also Configuring the .mff File.
<?xml version="1.0" encoding="UTF-8"?>
You have now finished creating a custom library and the .mff file which adapts it to MapForce. The custom .mff file can now be imported in MapForce as a library, see Importing the .mff File Into MapForce.