blob: b8681e9e19bbfb752a4bbe676fb74a2c61eaa120 (
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
35
|
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);
[TypeConverter(typeof(UriTypeConverter))]
public Uri Uri
{
get { return (Uri)GetValue(UriProperty); }
set { SetValue(UriProperty, value); }
}
public override async Task<string> GetJson()
{
var webClient = new HttpClient();
try
{
string json = await webClient.GetStringAsync(Uri);
return json;
}
catch
{
return null;
}
}
}
}
|