Exemplo n.º 1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest(HttpContext context)
        {
            HttpRequest request = context.Request;
            HttpResponse response = context.Response;
            JSONRpcCall call = JSON.ParseRPC(new System.IO.StreamReader(request.InputStream));
            object result = null;
            ISpellChecker spellchecker = new GoogleSpellChecker();

            switch (call.Method) {
                case "checkWords":
                    result = spellchecker.CheckWords((string) call.Args[0], (string[]) ((ArrayList) call.Args[1]).ToArray(typeof(string)));
                    break;

                case "getSuggestions":
                    result = spellchecker.GetSuggestions((string) call.Args[0], (string) call.Args[1]);
                    break;
            }

            // Serialize RPC output
            JSON.SerializeRPC(
                call.Id,
                null,
                result,
                response.OutputStream
            );
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest(HttpContext context)
        {
            HttpRequest   request      = context.Request;
            HttpResponse  response     = context.Response;
            JSONRpcCall   call         = JSON.ParseRPC(new System.IO.StreamReader(request.InputStream));
            object        result       = null;
            ISpellChecker spellchecker = new GoogleSpellChecker();

            switch (call.Method)
            {
            case "checkWords":
                result = spellchecker.CheckWords((string)call.Args[0], (string[])((ArrayList)call.Args[1]).ToArray(typeof(string)));
                break;

            case "getSuggestions":
                result = spellchecker.GetSuggestions((string)call.Args[0], (string)call.Args[1]);
                break;
            }

            // Serialize RPC output
            JSON.SerializeRPC(
                call.Id,
                null,
                result,
                response.OutputStream
                );
        }