Esempio n. 1
0
        /// <summary>
        /// Асинхронный макро-метод получения ресурса
        /// </summary>
        /// <param name="provider"></param>
        /// <param name="url"></param>
        /// <param name="config"></param>
        /// <returns></returns>
        public static async Task <IResource> GetResourceAsync(this IResourceProvider provider, string url, IResourceConfig config = null)
        {
            var request  = provider.CreateRequest(new Uri(url));
            var response = await request.GetResponse(config);

            var resource = await response.GetResource();

            return(resource);
        }
Esempio n. 2
0
        public void CanGetDataFullApi()
        {
            var request  = res.CreateRequest(new Uri("http://localhost"));
            var response = request.GetResponse();

            response.Wait();
            var resource = response.Result.GetResource();

            resource.Wait();
            var stream = resource.Result.Open();

            stream.Wait();
            Task <string> getresult;

            using (var sr = new StreamReader(stream.Result)) {
                getresult = sr.ReadToEndAsync();
            }
            getresult.Wait();
            var result = getresult.Result;

            StringAssert.Contains("<html", result);
        }