public void Init(object o) { Token = o; Type type = o.GetType(); var methos = type.GetMethods(); foreach (var item in methos) { if (item.IsPublic) { string methodName = item.Name; var args = item.GetParameters(); Type[] typeArg = new Type[args.Length]; for (int i = 0; i < args.Length; i++) { typeArg[i] = args[i].ParameterType; } methodName = MakeID.MakeMethodName(methodName, typeArg); if (!MethodInfoDiy.ContainsKey(methodName)) { MethodInfoDiy.Add(methodName, new MethodModuleDef(item)); } } } }
public override IMessage Invoke(IMessage reqMsg) { IMethodCallMessage ctorMsg = reqMsg as IMethodCallMessage; if (Call != null) { List <byte[]> arglist = new List <byte[]>(); Type[] types = ctorMsg.MethodSignature as Type[]; List <Type> argsType = new List <Type>(ctorMsg.ArgCount); object[] args = ctorMsg.Args; for (int i = 0; i < ctorMsg.ArgCount; i++) { argsType.Add(args[i].GetType()); arglist.Add(Serialization.PackSingleObject(argsType[i], args[i])); } ReturnValue returnval = Call(ModuleName, MakeID.MakeMethodName(ctorMsg.MethodName, types), argsType, arglist, (ctorMsg.MethodBase as MethodInfo).ReturnType); if (returnval.Args == null) { returnval.Args = args; } return(new ReturnMessage(returnval.returnVal, returnval.Args, returnval.Args == null ? 0 : returnval.Args.Length, null, ctorMsg)); } throw new Exception("event not register"); }