Page 5 of 5

Re: Using user context data(from HttpContext) in the custom functions

Posted: Tue Jul 16, 2019 10:00 pm
by Lech Kulikowski
Hello,

You can use the following code:

Code: Select all

public class MyFunction
{
    private const string Category = "MyFuncCategory";


    public static string MyFunc(string value)
    {
        return value.ToUpper();
    }


    public static void RegisterFunctions()
    {
        var ParamNames = new string[1];
        var ParamTypes = new Type[1];
        var ParamDescriptions = new string[1];


        ParamNames[0] = "value";
        ParamDescriptions[0] = "Descriptions";
        ParamTypes[0] = typeof(string);


        Stimulsoft.Report.Dictionary.StiFunctions.AddFunction(Category, "MyFunc", "MyFunc", "Description", typeof(MyFunction),
                                 typeof(string), "Return Description", ParamTypes, ParamNames, ParamDescriptions);
    }
}
Thank you.

Re: Using user context data(from HttpContext) in the custom functions

Posted: Wed Jul 17, 2019 7:31 am
by bra
Lech Kulikowski wrote: Tue Jul 16, 2019 10:00 pm Hello,

You can use the following code:

Code: Select all

public class MyFunction
{
    private const string Category = "MyFuncCategory";


    public static string MyFunc(string value)
    {
        return value.ToUpper();
    }


    public static void RegisterFunctions()
    {
        var ParamNames = new string[1];
        var ParamTypes = new Type[1];
        var ParamDescriptions = new string[1];


        ParamNames[0] = "value";
        ParamDescriptions[0] = "Descriptions";
        ParamTypes[0] = typeof(string);


        Stimulsoft.Report.Dictionary.StiFunctions.AddFunction(Category, "MyFunc", "MyFunc", "Description", typeof(MyFunction),
                                 typeof(string), "Return Description", ParamTypes, ParamNames, ParamDescriptions);
    }
}
Thank you.
As I said before, I cannot use static function declarations because I need to get values from instance (not class) members of Report