/// <summary>
/// 调用dll并处理dll中的时间,事件委托必须是jcom.DelegateClass类型
/// </summary>
/// <param name="t"></param>
/// <param name="n"></param>
/// <param name="c"></param>
/// <param name="m"></param>
/// <param name="ename">dll中的事件名称</param>
/// <param name="objs"></param>
/// <param name="objtarget">处理事件的类实例</param>
/// <param name="mname">处理事件的类实例方法名</param>
/// <returns></returns>
private static object _invoke(string t,string n,string c,string m,object[] objs,string ename,object objtarget,string mname)
{
if (Config.GetAsm(t) != null)
{
Type type = Config.GetAsm(t).GetType(string.Format("{0}.{1}", n, c));
object o = Activator.CreateInstance(type);
EventInfo _event = type.GetEvent(ename);
Type delegateType = typeof(jcom.DelegateClass);
Delegate _delegate = Delegate.CreateDelegate(delegateType, objtarget, mname);
_event.AddEventHandler(o, _delegate);
MethodInfo mt = type.GetMethod(m);
object result = mt.Invoke(o, objs);
return result;
}
else
{
return null;
}
}
这个是只处理一个事件的,可以修改一下,就能处理一批事件的了
调用类库方法,并处理类库事件
最新推荐文章于 2023-04-04 19:17:21 发布