How to modify the GetMethod function to automatically obtain the type and quantity of parameters and return values?
I have searched for a lot of information and still haven't found a solution. It is difficult to understand the usage of delegates here.
_____________________________________________________________________________________________
string code = """
{}public class Class1
{
public static int Add(int a, int b)
{ return a + b; }
}
""";
var c = CsScript.Compile(code);
var f = c.GetMethod<Func<int, int, int>>("Class1", "Add");
print.it(f(2, 5));
_____________________________________________________________________________________________
string code = """
{}public class Class2
{
public static string Join(string a, string b, int c)
{ return a + b + c; }
}
""";
var c = CsScript.Compile(code);
var f = c.GetMethod<Func<string, string, int, string>>("Class2", "Join");
print.it(f("hello ", "world ", 123));
_____________________________________________________________________________________________
string code = """
{}public class Class3 {
public static string Hi(string name) {
string r = $"hello {name} ";
return r;
}
}
""";
var c = CsScript.Compile(code);
var f = c.GetMethod<Func<string, string>>("Class3", "Hi");
print.it(f("Lisa"));
Http server Functions Corresponding modifications are also required
static partial class Functions {
public static int Temp(string code, string cla, string fun, xxx) {
var c = CsScript.Compile(code);
var f = c.GetMethod<Func<xxx>>(cla, fun);
return f(xxx);
}
}
I have searched for a lot of information and still haven't found a solution. It is difficult to understand the usage of delegates here.

_____________________________________________________________________________________________
string code = """
{}public class Class1
{
public static int Add(int a, int b)
{ return a + b; }
}
""";
var c = CsScript.Compile(code);
var f = c.GetMethod<Func<int, int, int>>("Class1", "Add");
print.it(f(2, 5));
_____________________________________________________________________________________________
string code = """
{}public class Class2
{
public static string Join(string a, string b, int c)
{ return a + b + c; }
}
""";
var c = CsScript.Compile(code);
var f = c.GetMethod<Func<string, string, int, string>>("Class2", "Join");
print.it(f("hello ", "world ", 123));
_____________________________________________________________________________________________
string code = """
{}public class Class3 {
public static string Hi(string name) {
string r = $"hello {name} ";
return r;
}
}
""";
var c = CsScript.Compile(code);
var f = c.GetMethod<Func<string, string>>("Class3", "Hi");
print.it(f("Lisa"));
Http server Functions Corresponding modifications are also required
static partial class Functions {
public static int Temp(string code, string cla, string fun, xxx) {
var c = CsScript.Compile(code);
var f = c.GetMethod<Func<xxx>>(cla, fun);
return f(xxx);
}
}
