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));
        }
Beispiel #2
0
        public static SpecialResult <TResult> GetSpecialResult <TSource>(TSource result)
        {
            SpecialResult <TResult> specialResult = new SpecialResult <TResult>()
            {
                IsSpecialResult = true
            };

            specialResult.Result = (TResult)(object)result;
            return(specialResult);
        }
Beispiel #3
0
        public static SpecialResult <TResult> GetSpecialResult <TSource>(Task <TSource> task)
        {
            SpecialResult <TResult> specialResult = new SpecialResult <TResult>()
            {
                IsSpecialResult = true
            };

            specialResult.Result = (TResult)(object)task.GetResult();
            return(specialResult);
        }
Beispiel #4
0
        public static Task <SpecialResult <TResult> > GetSpecialResultAsync <TSource>(TSource result)
        {
            SpecialResult <TResult> specialResult = new SpecialResult <TResult>()
            {
                IsSpecialResult = true
            };

            specialResult.Result = (TResult)(object)result;
            return(Task.FromResult(specialResult));
        }
Beispiel #5
0
        public static async Task <SpecialResult <TResult> > GetSpecialResultAsync <TSource>(Task <TSource> task)
        {
            SpecialResult <TResult> specialResult = new SpecialResult <TResult>()
            {
                IsSpecialResult = true
            };

            specialResult.Result = (TResult)(object)await task
#if CONFIGUREAWAIT_FALSE
                                   .ConfigureAwait(false)
#endif
            ;

            return(specialResult);
        }