2 using System.Globalization;
4 using System.Reflection;
8 namespace Tizen.NUI.Binding
10 internal class ExtentsTypeConverter : TypeConverter
12 public override object ConvertFromInvariantString(string value)
16 string[] parts = value.Split(',');
17 if (parts.Length == 4)
19 return new Extents(ushort.Parse(parts[0].Trim(), CultureInfo.InvariantCulture),
20 ushort.Parse(parts[1].Trim(), CultureInfo.InvariantCulture),
21 ushort.Parse(parts[2].Trim(), CultureInfo.InvariantCulture),
22 ushort.Parse(parts[3].Trim(), CultureInfo.InvariantCulture));
24 else if (parts.Length == 1)
26 return new Extents(ushort.Parse(parts[0].Trim(), CultureInfo.InvariantCulture));
30 throw new InvalidOperationException($"Cannot convert \"{value}\" into {typeof(Extents)}");
33 public override string ConvertToString(object value)
35 Extents extents = (Extents)value;
36 return extents.Start.ToString() + " " + extents.End.ToString() + " " + extents.Top.ToString() + " " + extents.Bottom.ToString();