[NUI]public the converter for Xaml (#2837)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / XamlBinding / VectorTypeConverter.cs
index 626eb45..cd13715 100755 (executable)
@@ -21,11 +21,16 @@ using System.Reflection;
 using System.Globalization;
 
 using Tizen.NUI;
+using System.ComponentModel;
 
 namespace Tizen.NUI.Binding
 {
-    internal class Vector2TypeConverter : TypeConverter
+    //Internal used, will never open
+    [EditorBrowsable(EditorBrowsableState.Never)]
+    public class Vector2TypeConverter : TypeConverter
     {
+        //Internal used, will never open
+        [EditorBrowsable(EditorBrowsableState.Never)]
         public override object ConvertFromInvariantString(string value)
         {
             if (value != null)
@@ -36,9 +41,11 @@ namespace Tizen.NUI.Binding
             throw new InvalidOperationException($"Cannot convert \"{value}\" into {typeof(Vector2)}");
         }
 
+        //Internal used, will never open
+        [EditorBrowsable(EditorBrowsableState.Never)]
         public override string ConvertToString(object value)
         {
-            return ToString((Vector2)value);
+            return ToString(value as Vector2);
         }
 
         internal static Vector2 FromString(string value)
@@ -55,12 +62,23 @@ namespace Tizen.NUI.Binding
 
         internal static string ToString(Vector2 value)
         {
-            return value.X.ToString() + " " + value.Y.ToString();
+            if (null != value)
+            {
+                return value.X.ToString() + " " + value.Y.ToString();
+            }
+            else
+            {
+                return null;
+            }
         }
     }
 
-    internal class Vector3TypeConverter : TypeConverter
+    //Internal used, will never open
+    [EditorBrowsable(EditorBrowsableState.Never)]
+    public class Vector3TypeConverter : TypeConverter
     {
+        //Internal used, will never open
+        [EditorBrowsable(EditorBrowsableState.Never)]
         public override object ConvertFromInvariantString(string value)
         {
             if (value != null)
@@ -77,15 +95,28 @@ namespace Tizen.NUI.Binding
             throw new InvalidOperationException($"Cannot convert \"{value}\" into {typeof(Vector3)}");
         }
 
+        //Internal used, will never open
+        [EditorBrowsable(EditorBrowsableState.Never)]
         public override string ConvertToString(object value)
         {
-            Vector3 vector = (Vector3)value;
-            return vector.X.ToString() + " " + vector.Y.ToString() + " " + vector.Z.ToString();
+            Vector3 vector = value as Vector3;
+            if (null != vector)
+            {
+                return vector.X.ToString() + " " + vector.Y.ToString() + " " + vector.Z.ToString();
+            }
+            else
+            {
+                return null;
+            }
         }
     }
 
-    internal class Vector4TypeConverter : TypeConverter
+    //Internal used, will never open
+    [EditorBrowsable(EditorBrowsableState.Never)]
+    public class Vector4TypeConverter : TypeConverter
     {
+        //Internal used, will never open
+        [EditorBrowsable(EditorBrowsableState.Never)]
         public override object ConvertFromInvariantString(string value)
         {
             if (value != null)
@@ -103,15 +134,28 @@ namespace Tizen.NUI.Binding
             throw new InvalidOperationException($"Cannot convert \"{value}\" into {typeof(Vector4)}");
         }
 
+        //Internal used, will never open
+        [EditorBrowsable(EditorBrowsableState.Never)]
         public override string ConvertToString(object value)
         {
-            Vector4 vector = (Vector4)value;
-            return vector.X.ToString() + " " + vector.Y.ToString() + " " + vector.Z.ToString() + " " + vector.W.ToString();
+            Vector4 vector = value as Vector4;
+            if (null != vector)
+            {
+                return vector.X.ToString() + " " + vector.Y.ToString() + " " + vector.Z.ToString() + " " + vector.W.ToString();
+            }
+            else
+            {
+                return null;
+            }
         }
     }
 
-    internal class RelativeVector2TypeConverter : TypeConverter
+    //Internal used, will never open
+    [EditorBrowsable(EditorBrowsableState.Never)]
+    public class RelativeVector2TypeConverter : TypeConverter
     {
+        //Internal used, will never open
+        [EditorBrowsable(EditorBrowsableState.Never)]
         public override object ConvertFromInvariantString(string value)
         {
             if (value != null)
@@ -127,15 +171,28 @@ namespace Tizen.NUI.Binding
             throw new InvalidOperationException($"Cannot convert \"{value}\" into {typeof(RelativeVector2)}");
         }
 
+        //Internal used, will never open
+        [EditorBrowsable(EditorBrowsableState.Never)]
         public override string ConvertToString(object value)
         {
-            RelativeVector2 vector = (RelativeVector2)value;
-            return vector.X.ToString() + " " + vector.Y.ToString();
+            RelativeVector2 vector = value as RelativeVector2;
+            if (null != vector)
+            {
+                return vector.X.ToString() + " " + vector.Y.ToString();
+            }
+            else
+            {
+                return null;
+            }
         }
     }
 
-    internal class RelativeVector3TypeConverter : TypeConverter
+    //Internal used, will never open
+    [EditorBrowsable(EditorBrowsableState.Never)]
+    public class RelativeVector3TypeConverter : TypeConverter
     {
+        //Internal used, will never open
+        [EditorBrowsable(EditorBrowsableState.Never)]
         public override object ConvertFromInvariantString(string value)
         {
             if (value != null)
@@ -152,15 +209,28 @@ namespace Tizen.NUI.Binding
             throw new InvalidOperationException($"Cannot convert \"{value}\" into {typeof(RelativeVector3)}");
         }
 
+        //Internal used, will never open
+        [EditorBrowsable(EditorBrowsableState.Never)]
         public override string ConvertToString(object value)
         {
-            RelativeVector3 vector = (RelativeVector3)value;
-            return vector.X.ToString() + " " + vector.Y.ToString() + " " + vector.Z.ToString();
+            RelativeVector3 vector = value as RelativeVector3;
+            if (null != vector)
+            {
+                return vector.X.ToString() + " " + vector.Y.ToString() + " " + vector.Z.ToString();
+            }
+            else
+            {
+                return null;
+            }
         }
     }
 
-    internal class RelativeVector4TypeConverter : TypeConverter
+    //Internal used, will never open
+    [EditorBrowsable(EditorBrowsableState.Never)]
+    public class RelativeVector4TypeConverter : TypeConverter
     {
+        //Internal used, will never open
+        [EditorBrowsable(EditorBrowsableState.Never)]
         public override object ConvertFromInvariantString(string value)
         {
             if (value != null)
@@ -178,10 +248,19 @@ namespace Tizen.NUI.Binding
             throw new InvalidOperationException($"Cannot convert \"{value}\" into {typeof(RelativeVector4)}");
         }
 
+        //Internal used, will never open
+        [EditorBrowsable(EditorBrowsableState.Never)]
         public override string ConvertToString(object value)
         {
-            RelativeVector4 vector = (RelativeVector4)value;
-            return vector.X.ToString() + " " + vector.Y.ToString() + " " + vector.Z.ToString() + " " + vector.W.ToString(); ;
+            RelativeVector4 vector = value as RelativeVector4;
+            if (null != vector)
+            {
+                return vector.X.ToString() + " " + vector.Y.ToString() + " " + vector.Z.ToString() + " " + vector.W.ToString();
+            }
+            else
+            {
+                return null;
+            }
         }
     }
 }