110,566
社区成员
发帖
与我相关
我的任务
分享
method.Invoke(this,context)
是类似这样子吗?
object[] Obj = new object[] { };
MethodInfo vMethodInfo = GetType().GetMethod(FunctionName);
if (vMethodInfo == null)
{
return;
}
vMethodInfo.Invoke(this, Obj);
public override void ProcessRequest(HttpContext context)
{
this.Init(context);
if (!this.PowerCheck())
{
context.Response.Write("{\"result\":false,\"message\":\"你没有权限访问该模块!\",type:\"NoAuthority\"}");
return;
}
string param = context.Request.Params["lx"];
try
{
Type type = this.GetType();
object o = Activator.CreateInstance(type);
// 1.根据方法名动态调用方法
type.InvokeMember(param, BindingFlags.Default | BindingFlags.InvokeMethod, null, o, new object[] { context });
}
catch (Exception ex)
{
context.Response.Write("参数错误");
throw ex;
}
}
代码大概是这样的,Init方法是初始化参数的