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

            return(Task.FromResult(result));
        }