ReadStreamAsync() public static method

public static ReadStreamAsync ( Stream stream ) : Task
stream System.IO.Stream
return Task
 public static IObservable <T> CreateObservableHttpStream <T>(this HttpClient httpClient, string url)
 {
     return(Observable.Using(() => httpClient,
                             client => client.GetStreamAsync(new Uri(url))
                             .ToObservable()
                             .Select(x => Observable.FromAsync(() => StreamHelper.ReadStreamAsync(x)).Repeat())
                             .Concat()
                             .Where(x => !string.IsNullOrWhiteSpace(x))
                             .Select(JsonConvert.DeserializeObject <T>)));
 }
Example #2
0
        public static IObservable <T> CreateObservableHttpStream <T>(this HttpClient httpClient, string url)
        {
#if __IOS__ || __ANDROID__ || NET45
            return(Observable.Using(() => httpClient,
                                    client => client.GetStreamAsync(new Uri(url))
                                    .ToObservable()
                                    .Select(x => Observable.FromAsync(() => StreamHelper.ReadStreamAsync(x)).Repeat())
                                    .Concat()
                                    .Where(x => !string.IsNullOrWhiteSpace(x))
                                    .Select(JsonConvert.DeserializeObject <T>)));
#endif
#if NETFX_CORE
            return(Observable.Using(() => httpClient,
                                    client => client.GetInputStreamAsync(new Uri(url))
                                    .AsTask()
                                    .ToObservable()
                                    .Select(x => Observable.FromAsync(() => StreamHelper.ReadStreamAsync(x.AsStreamForRead())).Repeat())
                                    .Concat()
                                    .Where(x => !string.IsNullOrWhiteSpace(x))
                                    .Select(JsonConvert.DeserializeObject <T>)));
#endif
        }