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); }
/// <summary> /// Finds the method information. /// </summary> public bool FindMethodInfo() { // find public method of the component MethodInfo = Type.GetMethod(MethodName, GenericArguments, ParamTypes); if (MethodInfo == null) { // find method of the interface var method = InterfaceType.GetMethod(MethodName, GenericArguments, ParamTypes); if (method != null && Type.GetInterface(InterfaceType.Name) != null) { // get the corresponding method of the component var map = Type.GetInterfaceMap(InterfaceType); var index = Array.IndexOf(map.InterfaceMethods, method); if (index >= 0) { MethodInfo = map.TargetMethods[index]; } } } return(MethodInfo != null); }
private Dictionary <int, MethodInfo> GetGrainMethods() { var grainMethods = new Dictionary <int, MethodInfo>(); foreach (var interfaceMethodInfo in GrainInterfaceData.GetMethods(InterfaceType)) { ParameterInfo[] parameters = interfaceMethodInfo.GetParameters(); var args = new Type[parameters.Length]; for (int i = 0; i < parameters.Length; i++) { args[i] = parameters[i].ParameterType; } MethodInfo methodInfo = InterfaceType.GetMethod(interfaceMethodInfo.Name, args) ?? interfaceMethodInfo; if (IsGrainMethod(methodInfo)) { grainMethods.Add(GrainInterfaceData.ComputeMethodId(methodInfo), methodInfo); } } return(grainMethods); }