using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using MercatorApi;
using MercatorUi;
// <ReferenceInclude>"CustomClassLibrary.dll"</ReferenceInclude>
namespace Main
{
public class Customizer : MercatorUi.ICustomizers.IInitReport
{
private static bool customFunctionsAdded = false; // static : voir commentaire plus bas (les registeredObjects sont statiques)
public void InitReport(object report) // the real type of report is FastReport.Report
{
FastReport.Report fastReport = (FastReport.Report)report;
if (!Api.StringArrayContains(fastReport.ReferencedAssemblies, "CustomClassLibrary.dll"))
fastReport.ReferencedAssemblies = Api.StringArrayAdd(fastReport.ReferencedAssemblies, "CustomClassLibrary.dll");
if (!customFunctionsAdded) // les registeredObjects sont statiques -> on ne doit donc exécuter qu'une seule fois ce code par instance de Mercator.
{
Type custom = typeof(CustomClassLibrary.Custom);
FastReport.Utils.RegisteredObjects.AddFunctionCategory("Custom", "Custom");
// la méthode MyMethod1 offre 2 signatures : il faut donc spécifier les types
FastReport.Utils.RegisteredObjects.AddFunction(custom.GetMethod("MyMethod1", new Type[2] { typeof(int), typeof(int) }), "Custom");
FastReport.Utils.RegisteredObjects.AddFunction(custom.GetMethod("MyMethod1", new Type[3] { typeof(int), typeof(int), typeof(int) }), "Custom");
// la méthode MyMethod2 offre une seule signature -> on ne doit pas spécifier les types
FastReport.Utils.RegisteredObjects.AddFunction(custom.GetMethod("MyMethod2"), "Custom");
customFunctionsAdded = true;
}
}
}
}