a115f40c3230f86a68fce374b282d8f3e52def99
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / XamlBinding / SizeTypeConverter.cs
1 using System;
2 using System.Linq;
3 using System.Reflection;
4
5 using Tizen.NUI;
6
7 namespace Tizen.NUI.Binding
8 {
9     internal class SizeTypeConverter : TypeConverter
10     {
11         public override object ConvertFromInvariantString(string value)
12         {
13             if (value != null)
14             {
15                 string[] parts = value.Split(',');
16                 if (parts.Length == 3)
17                 {
18                     return new Size(float.Parse(parts[0].Trim()), float.Parse(parts[1].Trim()), float.Parse(parts[2].Trim()));
19                 }
20             }
21
22             throw new InvalidOperationException($"Cannot convert \"{value}\" into {typeof(Size)}");
23         }
24     }
25
26     internal class Size2DTypeConverter : TypeConverter
27     {
28         public override object ConvertFromInvariantString(string value)
29         {
30             if (value != null)
31             {
32                 string[] parts = value.Split(',');
33                 if (parts.Length == 2)
34                 {
35                     return new Size2D(int.Parse(parts[0].Trim()), int.Parse(parts[1].Trim()));
36                 }
37             }
38
39             throw new InvalidOperationException($"Cannot convert \"{value}\" into {typeof(Size2D)}");
40         }
41     }
42 }