Lech Kulikowski wrote: ↑Sat Feb 02, 2019 9:16 am
Hello,
You can add necessary functions in the Dictionary of the designer.
Thank you.
I add functions as below:
Code: Select all
namespace DoctorCode.AspNetCore.Reports
{
public static class Test
{
public static string Print()
{
return "Alireza";
}
}
public static class PersianDateTimeHelper
{
public static void RegisterFanctions()
{
var types = new[]
{
new
{
Type = typeof(PersianDateTime),
Category = "PersianCulture",
GroupFunctionName = "DateTime"
},
new
{
Type = typeof(Test),
Category = "Test",
GroupFunctionName = ""
},
};
foreach (var item in types)
{
item.Type.RegisterFanctions(item.Category, item.GroupFunctionName);
}
}
private static void RegisterFanctions(this Type type, string category, string groupFunctionName)
{
var methods = type.GetMethods(BindingFlags.Static | BindingFlags.Public);
foreach (var method in methods)
{
StiFunctions.AddFunction(
category: category,
groupFunctionName: groupFunctionName,
functionName: method.Name,
description: "",
typeOfFunction: type,
returnType: method.ReturnType,
returnDescription: "",
argumentTypes: method.GetParameters().Select(p => p.ParameterType).ToArray(),
argumentNames: method.GetParameters().Select(p => p.Name).ToArray(),
argumentDescriptions: new string[0]);
}
}
}
}
All functions are registered and display in Dictionary but functions
from external assembly (typeof(PersianDateTime)) not work but typeof(Test) work.
It is necessary to define the type in the current assembly???