private void OnRMI(Message message, Protocols.RMIMessage rmimsg) { if (!string.IsNullOrEmpty(rmimsg.DeserializeError)) { message.Reply(new Protocols.Error() { Message = rmimsg.DeserializeError }); } else { RInterfaceInfo interfaceinfo = null; RMethodInfo methodinfo = null; RInterfaceFactory.Default.TryGet(rmimsg.Name, out interfaceinfo); interfaceinfo.TryGet(rmimsg.Method, out methodinfo); //Node.Loger.Process(LogType.DEBUG, "{0}.{1} invoke", rmimsg.Name, rmimsg.Method); RMethodResult result = methodinfo.Invoke(rmimsg.Parameters); if (result.Exception != null) { Protocols.Error error = new Protocols.Error() { Message = result.Exception.Message, StackTrace = result.Exception.StackTrace }; message.Reply(error); //Node.Loger.Process(LogType.DEBUG, "{0}.{1} invoke error {2}", rmimsg.Name, rmimsg.Method, result.Exception.Message); } else { if (result.IsVoid || result.Value == null) message.Reply(new Protocols.Success()); else message.Reply(result.Value); //Node.Loger.Process(LogType.DEBUG, "{0}.{1} invoke completed!", rmimsg.Name, rmimsg.Method); } } }
private void LoadMethodInfo() { foreach (System.Reflection.MethodInfo m in this.Type.GetRuntimeMethods()) { RMethodInfo method = new RMethodInfo(m, this.Target); method.Target = Target; if (mMethods.ContainsKey(method.Name)) { throw new SRException(string.Format("{0}.{1} has been registered", Type.Name, m.Name)); } mMethods[method.Name] = method; } }
public bool TryGet(string name, out RMethodInfo result) { return(mMethods.TryGetValue(name, out result)); }