Example #1
0
        public object Invoke(object target, MethodInfo methodInfo, object[] parameters)
        {
            if (methodInfo == null)
            {
                throw new ArgumentNullException("methodInfo is null");
            }
            // get class name
            // ReSharper disable once PossibleNullReferenceException
            string className = methodInfo.DeclaringType.FullName;

            ParameterInfo[] paramWrapper = methodInfo.GetParameters();

            var request = new MessageRequest();

            request.MessageId  = Guid.NewGuid().ToString();
            request.ClassName  = methodInfo.DeclaringType.FullName;
            request.MethodName = methodInfo.Name;
            request.ParamTypes = paramWrapper.Select(s => s.ParameterType).ToArray();
            request.Parameters = parameters;

            MessageSendHandler  handler  = RpcServerLoader.Instance.GetMessageSendHandler();
            MessageSendCallBack callBack = handler.SendRequest(request);

            return(callBack.Start());
        }
 public void SetMessageSendHandler(MessageSendHandler handler)
 {
     this.messageSendHandler = handler;  //TODO add thread safe lock
 }