blob: 8ca829f719a0ac6fb523085d9294f47cee9f4881 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
using System;
namespace Xamarin.Forms
{
public sealed class ImageSourceConverter : TypeConverter
{
public override object ConvertFromInvariantString(string value)
{
if (value != null)
{
Uri uri;
return Uri.TryCreate(value, UriKind.Absolute, out uri) && uri.Scheme != "file" ? ImageSource.FromUri(uri) : ImageSource.FromFile(value);
}
throw new InvalidOperationException(string.Format("Cannot convert \"{0}\" into {1}", value, typeof(ImageSource)));
}
}
}
|