blob: d732e25cf07afefcd2d84921d3b38c0a470aa92d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
using System;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
namespace Xamarin.Forms.Pages
{
public class UriJsonSource : JsonSource
{
public static readonly BindableProperty UriProperty = BindableProperty.Create(nameof(Uri), typeof(Uri),
typeof(UriJsonSource), null);
public Uri Uri
{
get { return (Uri)GetValue(UriProperty); }
set { SetValue(UriProperty, value); }
}
public override async Task<string> GetJson()
{
var webClient = new HttpClient(new ModernHttpClient.NativeMessageHandler());
try
{
string json = await webClient.GetStringAsync(Uri);
return json;
}
catch
{
return null;
}
}
}
}
|