public async Task ProcessRequestInternal(RequestContext request) { bool flag; object json; object[] objArray; object[] objArray1; object[] argument; try { request.ChangeCefBrowser(this.browserWindow.CefBrowser); JsApiService.JsResponse jsResponse = new JsApiService.JsResponse(request.OnProgress); JsApiService.JsResponse jsResponse1 = new JsApiService.JsResponse(request.OnResult); MethodData method = this.api.GetMethod(request.Method); ParameterInfo[] parameters = method.Parameters; int length = (int)method.Parameters.Length; flag = (length < 1 ? false : parameters[0].ParameterType == typeof(JsApiService.JsResponse)); bool flag1 = flag; switch (length) { case 0: { argument = new object[0]; break; } case 1: { objArray = (flag1 ? new object[] { jsResponse1 } : new object[] { request.Argument }); argument = objArray; break; } case 2: { objArray1 = (flag1 ? new object[] { jsResponse, jsResponse1 } : new object[] { request.Argument, jsResponse1 }); argument = objArray1; break; } case 3: { argument = new object[] { request.Argument, jsResponse, jsResponse1 }; break; } default: { throw new ArgumentException("Unknown number of parameters in microapi method."); } } object obj = await this.api.InvokeAsync(request.Method, argument); object obj1 = obj; JsonResult jsonResult = obj1 as JsonResult; JsApiService.JsResponse jsResponse2 = jsResponse1; if (jsonResult != null) { json = jsonResult.Json; } else { json = obj1; } jsResponse2(json); } catch (MissingMethodException missingMethodException) { request.OnFault(new { Reason = "missing-method", Data = null }); } catch (Exception exception) { Exception innerException = exception; TargetInvocationException targetInvocationException = innerException as TargetInvocationException; if (targetInvocationException != null) { innerException = targetInvocationException.InnerException; } string reason = null; object info = null; JsApiException jsApiException = innerException as JsApiException; if (jsApiException != null) { reason = jsApiException.Reason; info = jsApiException.Info; } InvocationException invocationException = innerException as InvocationException; if (invocationException != null) { PlatformException rootCause = invocationException.RootCause as PlatformException; if (rootCause != null) { reason = rootCause.RootCauseClassname; } } string jsStyleClassName = reason; if (jsStyleClassName == null) { jsStyleClassName = WintermintApiHost.GetJsStyleClassName(innerException); } reason = jsStyleClassName; request.OnFault(new { Reason = reason, Data = info }); } return; throw new ArgumentException("Unknown number of parameters in microapi method."); }
public async Task ProcessRequestInternal(RequestContext request) { try { request.ChangeCefBrowser(this.browserWindow.CefBrowser); JsApiService.JsResponse onProgress = new JsApiService.JsResponse(request.OnProgress); JsApiService.JsResponse onResult = new JsApiService.JsResponse(request.OnResult); MethodData data = this.api.GetMethod(request.Method); ParameterInfo[] parameters = data.Parameters; int parameterCount = data.Parameters.Length; bool param1IsJsResponse = parameterCount >= 1 && parameters[0].ParameterType == typeof (JsApiService.JsResponse); object[] args; switch (parameterCount) { case 0: args = new object[0]; break; case 1: object[] objArray1; if (!param1IsJsResponse) objArray1 = new object[1] { request.Argument }; else objArray1 = new object[1] { (object) onResult }; args = objArray1; break; case 2: object[] objArray2; if (!param1IsJsResponse) objArray2 = new object[2] { request.Argument, (object) onResult }; else objArray2 = new object[2] { (object) onProgress, (object) onResult }; args = objArray2; break; case 3: args = new object[3] { request.Argument, (object) onProgress, (object) onResult }; break; default: throw new ArgumentException("Unknown number of parameters in microapi method."); } object result = await this.api.InvokeAsync(request.Method, args); JsonResult json = result as JsonResult; onResult(json != null ? (object) json.Json : result); } catch (MissingMethodException ex) { request.OnFault((object) new { Reason = "missing-method", Data = (object) null }); } catch (Exception ex) { Exception exception = ex; TargetInvocationException invocationException1 = exception as TargetInvocationException; if (invocationException1 != null) exception = invocationException1.InnerException; string str = (string) null; object obj = (object) null; JsApiException jsApiException = exception as JsApiException; if (jsApiException != null) { str = jsApiException.Reason; obj = jsApiException.Info; } InvocationException invocationException2 = exception as InvocationException; if (invocationException2 != null) { PlatformException platformException = invocationException2.RootCause as PlatformException; if (platformException != null) str = platformException.RootCauseClassname; } request.OnFault((object) new { Reason = (str ?? WintermintApiHost.GetJsStyleClassName((object) exception)), Data = obj }); } }