private MessageBridgeResponse OnExecuteExtensionFunction(MessageBridgeRequest request) { if (request.Name == EXECUTE_EXT_JAVASCRIPT_FUNCION) { var owner = BrowserSideBridge.Owner; var extensionName = request.Arguments[0].GetString(); var functionName = request.Arguments[1].GetString(); var arguments = JavaScriptValue.FromJson(request.Arguments[2].GetString()).ToArray(); var uuid = new Guid(request.Arguments[3].GetString()); var extension = WinFormium.Runtime.Container.GetInstance <JavaScriptExtensionBase>(extensionName); if (extension == null) { return(MessageBridgeResponse.CreateFailureResponse($"JavaScript extension handler is not found.")); } var function = extension.FunctionHandlers.SingleOrDefault(x => x.FuntionName.Equals(functionName)); if (function == null) { return(MessageBridgeResponse.CreateFailureResponse($"{functionName} is not defined.")); } if (function.FunctionType == JavaScriptExtensionFunctionHandlerType.BrowserSideFunction && function.BrowserSideFunction != null) { JavaScriptValue retval = null; owner.InvokeIfRequired(() => { retval = function.BrowserSideFunction.Invoke(owner, arguments); }); retval = retval ?? JavaScriptValue.CreateNull(); var response = MessageBridgeResponse.CreateSuccessResponse(); response.Arguments.Add(MessageValue.CreateString(retval.ToDefinition())); return(response); } else if (function.FunctionType == JavaScriptExtensionFunctionHandlerType.BrowserSideAsyncFunction && function.BrowserSideAsyncFunction != null) { owner.InvokeIfRequired(() => { function.BrowserSideAsyncFunction.Invoke(owner, arguments, new JavaScriptAsyncFunctionCallback(owner.GetMainFrame(), uuid, this)); }); var response = MessageBridgeResponse.CreateSuccessResponse(); return(response); } return(MessageBridgeResponse.CreateFailureResponse($"{functionName} is not defined.")); } //return MessageBridgeResponse.CreateFailureResponse("Function is not defined."); return(null); }