protected sealed override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext) { object[] parameters; object data = executionContext.GetService(InterfaceType); MethodInfo invoke = InterfaceType.GetMethod(MethodName); ParameterInfo[] pars = invoke.GetParameters(); parameters = new object [pars.Length]; for (int i = 0; i < pars.Length; i++) { ParameterBindings.Add(new WorkflowParameterBinding(pars[i].Name)); } // User may set the ParameterBindings OnMethodInvoking(new EventArgs()); for (int i = 0; i < pars.Length; i++) { parameters[i] = (ParameterBindings [pars[i].Name]).Value; } InterfaceType.InvokeMember(MethodName, BindingFlags.InvokeMethod, null, data, parameters); OnMethodInvoked(new EventArgs()); NeedsExecution = false; return(ActivityExecutionStatus.Closed); }
private object Execute(IRequestMessage requestMessage) { try { return(InterfaceType.InvokeMember(requestMessage.MethodName, BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.Public, null, Handler, requestMessage.Args)); } catch (MissingMemberException) { throw new InvalidOperationException(string.Format( "Unable to call {0}({1}) method on {2} handler: no matching method was found.", requestMessage.MethodName, string.Join(",", requestMessage.Args.Select(a => a == null ? "null" : a.GetType().Name)), HandledMessageType)); } catch (TargetInvocationException e) { throw e.InnerException; } }