Beispiel #1
0
        public static SpecialResult <TResult> GetSpecialResult <TResult>(HttpResponseMessage responseMessage)
        {
            if (typeof(TResult) == typeof(Task))
            {
                return(SpecialResult <TResult> .GetSpecialResult(TaskEx.CompletedTask));
            }
            else if (typeof(TResult) == typeof(string))
            {
                return(SpecialResult <TResult> .GetSpecialResult(responseMessage.Content.ReadAsStringAsync()));
            }
            else if (typeof(TResult) == typeof(Stream))
            {
                return(SpecialResult <TResult> .GetSpecialResult(responseMessage.Content.ReadAsStreamAsync()));
            }
            else if (typeof(TResult) == typeof(byte[]))
            {
                return(SpecialResult <TResult> .GetSpecialResult(responseMessage.Content.ReadAsByteArrayAsync()));
            }
            else if (typeof(TResult) == typeof(HttpResponseMessage))
            {
                return(SpecialResult <TResult> .GetSpecialResult(responseMessage));
            }
            else if (typeof(TResult) == typeof(HttpContent))
            {
                return(SpecialResult <TResult> .GetSpecialResult(responseMessage.Content));
            }
            SpecialResult <TResult> result = new SpecialResult <TResult>();

            return(result);
        }