Ejemplo n.º 1
0
            public object Invoke(object target, System.Reflection.MethodInfo method, object[] parameters)
            {
                var arguments = method.GetParameters();
                var argCount  = arguments.Length;
                var args      = new DictionaryWrapper();

                for (int i = 0; i < argCount; i++)
                {
                    args[arguments[i].Name] = parameters[i];
                }


                var operationName = method.Name;

                var req = ServiceRequest.Create(ServiceName, operationName, args);

                if (ServiceDispatcherName.HasValue())
                {
                    req.Arguments.Add(ServiceDispatcher.ServiceDispatcherParameterName, ServiceDispatcherName);
                }

                var resp = ServiceDispatcher.Dispatch(req);

                if (resp.Success)
                {
                    return(resp.Result);
                }
                else
                {
                    throw resp.Exception;
                }
            }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="serviceName"></param>
        /// <param name="operationName"></param>
        /// <param name="requestArgs"></param>
        /// <returns></returns>
        public static TResult Dispatch <TResult>(string serviceName, string operationName, object requestArgs)
        {
            var req  = ServiceRequest.Create(serviceName, operationName, requestArgs);
            var resp = ServiceDispatcher.Dispatch(req);

            if (resp.Exception != null)
            {
                throw resp.Exception;
            }
            return((TResult)resp.Result);
        }
Ejemplo n.º 3
0
            public override IMessage Invoke(IMessage message)
            {
                var methodMessage = message as IMethodCallMessage;
                var method        = methodMessage.MethodBase;

                var argCount = methodMessage.ArgCount;
                var args     = new DictionaryWrapper();

                for (int i = 0; i < argCount; i++)
                {
                    args[methodMessage.GetArgName(i)] = methodMessage.GetArg(i);
                }


                var operationName = method.Name;

                var req = ServiceRequest.Create(ServiceName, operationName, args);

                if (ServiceDispatcherName.HasValue())
                {
                    req.Arguments.Add(ServiceDispatcher.ServiceDispatcherParameterName, ServiceDispatcherName);
                }
                try
                {
                    var resp = ServiceDispatcher.Dispatch(req);

                    if (resp.Success)
                    {
                        return(new ReturnMessage(resp.Result, null, 0, methodMessage.LogicalCallContext, methodMessage));
                    }
                    else
                    {
                        return(new ReturnMessage(resp.Exception, methodMessage));
                    }
                }
                catch (Exception ex)
                {
                    return(new ReturnMessage(ex, methodMessage));
                }
            }
Ejemplo n.º 4
0
 /// <summary>
 ///
 /// </summary>
 /// <typeparam name="TResult"></typeparam>
 /// <param name="serviceName"></param>
 /// <param name="operationName"></param>
 /// <returns></returns>
 public static TResult Dispatch <TResult>(string serviceName, string operationName)
 {
     return(ServiceDispatcher.Dispatch <TResult>(serviceName, operationName, null));
 }