public InvokeResult ServiceInvokeMethod(InvokeInfo parameters) { InvokeResult res = null; this._currentOperation = ServiceOperationType.InvokeMethod; try { res = this.InvokeMethod(parameters); } catch (Exception ex) { while (ex.InnerException != null) { ex = ex.InnerException; } res = new InvokeResult() { result = null, error = new ErrorInfo(ex.Message, ex.GetType().Name) }; this.OnError(ex); } finally { this._currentOperation = ServiceOperationType.None; } return(res); }
protected InvokeResult InvokeMethod(InvokeInfo invokeInfo) { List <MethodDescription> methodList = this.EnsureMetadataInitialized().methodDescriptions; MethodDescription method = methodList.Where((m) => m.methodName == invokeInfo.methodName && m.isQuery == false).FirstOrDefault(); if (method == null) { throw new DomainServiceException(string.Format(ErrorStrings.ERR_METH_NAME_INVALID, invokeInfo.methodName)); } this.Authorizer.CheckUserRightsToExecute(method.methodInfo); List <object> methParams = new List <object>(); for (var i = 0; i < method.parameters.Count; ++i) { methParams.Add(invokeInfo.paramInfo.GetValue(method.parameters[i].name, method, this.DataHelper)); } object meth_result = method.methodInfo.Invoke(this, methParams.ToArray()); InvokeResult res = new InvokeResult(); if (method.methodResult) { res.result = meth_result; } return(res); }