protected override bool ProcessRequest(CefRequest request, CefCallback callback)
        {
            var isSchemeRegistered = _requestSchemeProvider?.IsSchemeRegistered(request.Url);

            if (isSchemeRegistered.HasValue && isSchemeRegistered.Value)
            {
                var uri  = new Uri(request.Url);
                var path = uri.LocalPath;

                bool isRequestAsync = _routeProvider.IsActionRouteAsync(path);
                if (isRequestAsync)
                {
                    ProcessRequestAsync(path);
                }
                else
                {
                    ProcessRequest(path);
                }

                return(true);
            }

            Logger.Instance.Log.LogWarning($"Url {request.Url} is not of a registered custom scheme.");
            callback.Dispose();
            return(false);

            #region Process Request

            void ProcessRequest(string path)
            {
                Task.Run(() =>
                {
                    using (callback)
                    {
                        try
                        {
                            var response = new ChromelyResponse();
                            if (string.IsNullOrEmpty(path))
                            {
                                response.ReadyState = (int)ReadyState.ResponseIsReady;
                                response.Status     = (int)HttpStatusCode.BadRequest;
                                response.StatusText = "Bad Request";

                                _chromelyResponse = response;
                            }
                            else
                            {
                                var parameters = request.Url.GetParameters();
                                var postData   = GetPostData(request);

                                var jsonRequest   = _serializerUtil.ObjectToJson(request);
                                _chromelyResponse = _requestTaskRunner.Run(request.Identifier.ToString(), path, parameters, postData, jsonRequest);
                                string jsonData   = _serializerUtil.EnsureResponseDataIsJson(_chromelyResponse.Data);
                                _responseBytes    = Encoding.UTF8.GetBytes(jsonData);
                            }
                        }
                        catch (Exception exception)
                        {
                            Logger.Instance.Log.LogError(exception, exception.Message);

                            _chromelyResponse =
                                new ChromelyResponse
                            {
                                Status = (int)HttpStatusCode.BadRequest,
                                Data   = "An error occured."
                            };
                        }
                        finally
                        {
                            callback.Continue();
                        }
                    }
                });
            }

            #endregion

            #region Process Request Async

            void ProcessRequestAsync(string path)
            {
                Task.Run(async() =>
                {
                    using (callback)
                    {
                        try
                        {
                            var response = new ChromelyResponse();
                            if (string.IsNullOrEmpty(path))
                            {
                                response.ReadyState = (int)ReadyState.ResponseIsReady;
                                response.Status     = (int)System.Net.HttpStatusCode.BadRequest;
                                response.StatusText = "Bad Request";

                                _chromelyResponse = response;
                            }
                            else
                            {
                                var parameters = request.Url.GetParameters();
                                var postData   = GetPostData(request);

                                var jsonRequest   = _serializerUtil.ObjectToJson(request);
                                _chromelyResponse = await _requestTaskRunner.RunAsync(request.Identifier.ToString(), path, parameters, postData, jsonRequest);
                                string jsonData   = _serializerUtil.EnsureResponseDataIsJson(_chromelyResponse.Data);

                                _responseBytes = Encoding.UTF8.GetBytes(jsonData);
                            }
                        }
                        catch (Exception exception)
                        {
                            Logger.Instance.Log.LogError(exception, exception.Message);

                            _chromelyResponse =
                                new ChromelyResponse
                            {
                                Status = (int)HttpStatusCode.BadRequest,
                                Data   = "An error occured."
                            };
                        }
                        finally
                        {
                            callback.Continue();
                        }
                    }
                });
            }

            #endregion
        }
        protected override bool ProcessRequest(CefRequest request, CefCallback callback)
        {
            var isSchemeRegistered = _requestSchemeProvider?.IsSchemeRegistered(request.Url);

            if (isSchemeRegistered.HasValue && isSchemeRegistered.Value)
            {
                var uri  = new Uri(request.Url);
                var path = uri.LocalPath;

                bool isRequestAsync = _routeProvider.IsActionRouteAsync(path);
                if (isRequestAsync)
                {
                    ProcessRequestAsync(path);
                }
                else
                {
                    ProcessRequest(path);
                }

                return(true);
            }
            else
            {
                _chromelyResponse = _chromelyErrorHandler.HandleRouteNotFound(request.Identifier.ToString(), request.Url);
                string jsonData = _serializerUtil.EnsureResponseDataIsJson(_chromelyResponse.Data);
                _responseBytes = Encoding.UTF8.GetBytes(jsonData);
            }

            callback.Dispose();
            return(false);

            #region Process Request

            void ProcessRequest(string path)
            {
                Task.Run(() =>
                {
                    using (callback)
                    {
                        try
                        {
                            if (string.IsNullOrWhiteSpace(path))
                            {
                                _chromelyResponse = _chromelyErrorHandler.HandleRouteNotFound(request.Identifier.ToString(), path);
                                string jsonData   = _serializerUtil.EnsureResponseDataIsJson(_chromelyResponse.Data);
                                _responseBytes    = Encoding.UTF8.GetBytes(jsonData);
                            }
                            else
                            {
                                var parameters = request.Url.GetParameters(request.ReferrerURL);
                                var postData   = GetPostData(request);

                                var jsonRequest   = _serializerUtil.ObjectToJson(request);
                                _chromelyResponse = _requestTaskRunner.Run(request.Identifier.ToString(), path, parameters, postData, jsonRequest);
                                string jsonData   = _serializerUtil.EnsureResponseDataIsJson(_chromelyResponse.Data);
                                _responseBytes    = Encoding.UTF8.GetBytes(jsonData);
                            }
                        }
                        catch (Exception exception)
                        {
                            var chromelyRequest = new ChromelyRequest()
                            {
                                Id = request.Identifier.ToString(), RouteUrl = request.Url
                            };
                            _chromelyResponse = _chromelyErrorHandler.HandleError(chromelyRequest, exception);
                            string jsonData   = _serializerUtil.EnsureResponseDataIsJson(_chromelyResponse.Data);
                            _responseBytes    = Encoding.UTF8.GetBytes(jsonData);
                        }
                        finally
                        {
                            callback.Continue();
                        }
                    }
                });
            }

            #endregion

            #region Process Request Async

            void ProcessRequestAsync(string path)
            {
                Task.Run(async() =>
                {
                    using (callback)
                    {
                        try
                        {
                            if (string.IsNullOrWhiteSpace(path))
                            {
                                _chromelyResponse = _chromelyErrorHandler.HandleRouteNotFound(request.Identifier.ToString(), path);
                                string jsonData   = _serializerUtil.EnsureResponseDataIsJson(_chromelyResponse.Data);
                                _responseBytes    = Encoding.UTF8.GetBytes(jsonData);
                            }
                            else
                            {
                                var parameters = request.Url.GetParameters(request.ReferrerURL);
                                var postData   = GetPostData(request);

                                var jsonRequest   = _serializerUtil.ObjectToJson(request);
                                _chromelyResponse = await _requestTaskRunner.RunAsync(request.Identifier.ToString(), path, parameters, postData, jsonRequest);
                                string jsonData   = _serializerUtil.EnsureResponseDataIsJson(_chromelyResponse.Data);

                                _responseBytes = Encoding.UTF8.GetBytes(jsonData);
                            }
                        }
                        catch (Exception exception)
                        {
                            var chromelyRequest = new ChromelyRequest()
                            {
                                Id = request.Identifier.ToString(), RouteUrl = request.Url
                            };
                            _chromelyResponse = _chromelyErrorHandler.HandleError(chromelyRequest, exception);
                            string jsonData   = _serializerUtil.EnsureResponseDataIsJson(_chromelyResponse.Data);
                            _responseBytes    = Encoding.UTF8.GetBytes(jsonData);
                        }
                        finally
                        {
                            callback.Continue();
                        }
                    }
                });
            }

            #endregion
        }
        /// <summary>
        /// The process request async.
        /// </summary>
        /// <param name="request">
        /// The request.
        /// </param>
        /// <param name="callback">
        /// The callback.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public override CefReturnValue ProcessRequestAsync(IRequest request, ICallback callback)
        {
            var scheme = _requestSchemeHandlerProvider?.GetScheme(request.Url);

            if (scheme != null && scheme.UrlSchemeType == UrlSchemeType.LocalRquest)
            {
                _stream = null;
                var uri  = new Uri(request.Url);
                var path = uri.LocalPath;
                _mimeType = "application/json";

                bool isRequestAsync = _routeProvider.IsActionRouteAsync(path);
                if (isRequestAsync)
                {
                    ProcessRequestAsync(path);
                }
                else
                {
                    ProcessRequest(path);
                }
            }

            return(CefReturnValue.ContinueAsync);

            #region Process Request

            void ProcessRequest(string path)
            {
                Task.Run(() =>
                {
                    using (callback)
                    {
                        try
                        {
                            var response = new ChromelyResponse();
                            if (string.IsNullOrEmpty(path))
                            {
                                response.ReadyState = (int)ReadyState.ResponseIsReady;
                                response.Status     = (int)System.Net.HttpStatusCode.BadRequest;
                                response.StatusText = "Bad Request";

                                _chromelyResponse = response;
                            }
                            else
                            {
                                var parameters = request.Url.GetParameters();
                                var postData   = request.GetPostData();

                                _chromelyResponse = _requestTaskRunner.Run(path, parameters, postData);
                                string jsonData   = _serializerUtil.EnsureResponseDataIsJson(_chromelyResponse.Data);
                                var content       = Encoding.UTF8.GetBytes(jsonData);
                                _stream           = new MemoryStream();
                                _stream.Write(content, 0, content.Length);
                            }
                        }
                        catch (Exception exception)
                        {
                            _stream = null;
                            Logger.Instance.Log.LogError(exception, exception.Message);

                            _chromelyResponse =
                                new ChromelyResponse
                            {
                                Status = (int)HttpStatusCode.BadRequest,
                                Data   = "An error occured."
                            };
                        }

                        if (_stream == null)
                        {
                            callback.Cancel();
                        }
                        else
                        {
                            SetResponseInfoOnSuccess();
                            callback.Continue();
                        }
                    }
                });
            }

            #endregion

            #region Process Request Async

            void ProcessRequestAsync(string path)
            {
                Task.Run(async() =>
                {
                    using (callback)
                    {
                        try
                        {
                            var response = new ChromelyResponse();
                            if (string.IsNullOrEmpty(path))
                            {
                                response.ReadyState = (int)ReadyState.ResponseIsReady;
                                response.Status     = (int)System.Net.HttpStatusCode.BadRequest;
                                response.StatusText = "Bad Request";

                                _chromelyResponse = response;
                            }
                            else
                            {
                                var parameters = request.Url.GetParameters();
                                var postData   = request.GetPostData();

                                _chromelyResponse = await _requestTaskRunner.RunAsync(path, parameters, postData);
                                string jsonData   = _serializerUtil.EnsureResponseDataIsJson(_chromelyResponse.Data);
                                var content       = Encoding.UTF8.GetBytes(jsonData);
                                _stream           = new MemoryStream();
                                _stream.Write(content, 0, content.Length);
                            }
                        }
                        catch (Exception exception)
                        {
                            _stream = null;
                            Logger.Instance.Log.LogError(exception, exception.Message);

                            _chromelyResponse =
                                new ChromelyResponse
                            {
                                Status = (int)HttpStatusCode.BadRequest,
                                Data   = "An error occured."
                            };
                        }

                        if (_stream == null)
                        {
                            callback.Cancel();
                        }
                        else
                        {
                            SetResponseInfoOnSuccess();
                            callback.Continue();
                        }
                    }
                });
            }

            #endregion
        }