summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core/UriTypeConverter.cs
blob: 0a24cab3ed4a2efe8366d0954cc1c32044062139 (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
using System;

namespace Xamarin.Forms
{
	public class UriTypeConverter : TypeConverter
	{
		public override object ConvertFromInvariantString(string value)
		{
			if (string.IsNullOrWhiteSpace(value))
				return null;
			return new Uri(value, UriKind.RelativeOrAbsolute);
		}

		bool CanConvert(Type type)
		{
			if (type == typeof(string))
				return true;
			if (type == typeof(Uri))
				return true;

			return false;
		}
	}
}