Exemplo n.º 1
0
        internal static DetectData Detect(string text)
        {
            if (text == null)
            {
                throw new ArgumentNullException("text");
            }

            DetectRequest request = new DetectRequest(text);

            WebRequest webRequest;

            if (Timeout != 0)
            {
                webRequest = request.GetWebRequest(Timeout);
            }
            else
            {
                webRequest = request.GetWebRequest();
            }

            DetectData responseData;

            try
            {
                responseData = RequestUtility.GetResponseData <DetectData>(webRequest);
            }
            catch (GoogleAPIException ex)
            {
                throw new TranslateException(string.Format("request:\"{0}\"", request), ex);
            }

            return(responseData);
        }
Exemplo n.º 2
0
        internal IAsyncResult BeginNativeDetect(string text, AsyncCallback callback, object state)
        {
            if (text == null)
            {
                throw new ArgumentNullException("text");
            }

            var request = new DetectRequest {
                Query = text
            };

            return(this.BeginGetResponseData(request, callback, state));
        }
Exemplo n.º 3
0
        internal DetectData NativeDetect(string text)
        {
            if (text == null)
            {
                throw new ArgumentNullException("text");
            }

            var request = new DetectRequest {
                Query = text
            };

            var responseData = this.GetResponseData <DetectData>(request);

            return(responseData);
        }
        internal static DetectData Detect(string text)
        {
            if (text == null)
            {
                throw new ArgumentNullException("text");
            }

            DetectRequest request = new DetectRequest(text);

            WebRequest webRequest;
            if (Timeout != 0)
            {
                webRequest = request.GetWebRequest(Timeout);
            }
            else
            {
                webRequest = request.GetWebRequest();
            }

            DetectData responseData;
            try
            {
                responseData = RequestUtility.GetResponseData<DetectData>(webRequest);
            }
            catch (GoogleAPIException ex)
            {
                throw new TranslateException(string.Format("request:\"{0}\"", request), ex);
            }

            return responseData;
        }
        internal IAsyncResult BeginNativeDetect(string text, AsyncCallback callback, object state)
        {
            if (text == null)
            {
                throw new ArgumentNullException("text");
            }

            var request = new DetectRequest { Query = text };

            return this.BeginGetResponseData(request, callback, state);
        }
        internal DetectData NativeDetect(string text)
        {
            if (text == null)
            {
                throw new ArgumentNullException("text");
            }

            var request = new DetectRequest { Query = text };

            var responseData = this.GetResponseData<DetectData>(request);

            return responseData;
        }