/// <summary> /// Invokes the action with the parsed parameters. /// </summary> /// <returns>0 for success.</returns> public int Invoke() { var args = MethodParameters .OrderBy(map => map.Position) .Select(row => row.Value) .ToArray() ; this.CommonParameters.ToList().ForEach(cp => cp.WriteToCommand()); this.Command.OnBeforeExecute(this); var result = MethodInfo.Invoke(Command, args); int exitCode = 0; if (result is int) { exitCode = (int)result; } if (result is bool) { exitCode = (bool)result ? 0 : -1; } return(this.Command.OnAfterExecute(this, exitCode)); }
private MethodParameter FindByIndex(int i) { if (i >= MethodParameters.Count) { return(null); } return(MethodParameters .OrderBy(p => p.Position) .ToArray()[i] ); }