Skip to content

Instantly share code, notes, and snippets.

@BryanOroxon
Created December 30, 2019 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BryanOroxon/cf59d07a79772f93bbd5511ee06c5f6b to your computer and use it in GitHub Desktop.
Save BryanOroxon/cf59d07a79772f93bbd5511ee06c5f6b to your computer and use it in GitHub Desktop.
WebDataService.cs
using GifInMotion.Models;
using GifInMotion.Services;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using Xamarin.Forms;
[assembly: Dependency(typeof(WebDataService))]
namespace GifInMotion.Services
{
public class WebDataService : IDataService
{
HttpClient httpClient;
HttpClient Client => httpClient ?? (httpClient = new HttpClient());
public async Task<IEnumerable<Movies>> GetMoviesAsync()
{
var json = await Client.GetStringAsync("https://raw.githubusercontent.com/BryanOroxon/GifInMotion/master/GifInMotion/GifInMotion/Data/movie.json");
var all = Movies.FromJson(json);
return all;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment