summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core/ConstraintTypeConverter.cs
blob: 8cc452299632fb74758face92b9d14d12a27927d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
using System;
using System.Globalization;

namespace Xamarin.Forms
{
	public class ConstraintTypeConverter : TypeConverter
	{
		public override object ConvertFromInvariantString(string value)
		{
			double size;
			if (value != null && double.TryParse(value, NumberStyles.Number, CultureInfo.InvariantCulture, out size))
				return Constraint.Constant(size);

			throw new InvalidOperationException(string.Format("Cannot convert \"{0}\" into {1}", value, typeof(Color)));
		}
	}
}