Exemple #1
0
        private RestReturnType CheckReturnType(HttpResponseMessage response)
        {
            if (null == response)
            {
                throw new ArgumentNullException("response");
            }

            RestReturnType rt          = RestReturnType.Detect;
            string         contentType = ContentHelper.GetContentType(response);

            if (string.IsNullOrEmpty(contentType))
            {
                rt = RestReturnType.Detect;
            }
            else if (ContentHelper.IsJson(contentType))
            {
                rt = RestReturnType.Json;
            }
            else if (ContentHelper.IsXml(contentType))
            {
                rt = RestReturnType.Xml;
            }

            return(rt);
        }
Exemple #2
0
        private RestReturnType CheckReturnType(WebResponse response)
        {
            if (response == null)
            {
                throw new ArgumentNullException("response");
            }
            RestReturnType detect      = RestReturnType.Detect;
            string         contentType = ContentHelper.GetContentType(response);

            if (string.IsNullOrEmpty(contentType))
            {
                return(RestReturnType.Detect);
            }
            if (ContentHelper.IsJson(contentType))
            {
                return(RestReturnType.Json);
            }
            if (ContentHelper.IsXml(contentType))
            {
                detect = RestReturnType.Xml;
            }
            return(detect);
        }