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

namespace Xamarin.Forms
{
	[Xaml.ProvideCompiled("Xamarin.Forms.Core.XamlC.ConstraintTypeConverter")]
	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(Constraint)));
		}
	}
}