[NUI] Modify acr apis
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / KeyValue.cs
index 87c5445..cf0e8c8 100755 (executable)
@@ -16,6 +16,8 @@
  */
 
 using System;
+using System.ComponentModel;
+using System.Diagnostics.CodeAnalysis;
 using Tizen.NUI.Binding;
 
 namespace Tizen.NUI
@@ -23,21 +25,31 @@ namespace Tizen.NUI
     /// <summary>
     /// KeyValue class.
     /// </summary>
-    public class KeyValue
+    public class KeyValue : IDisposable
     {
+        private bool disposed = false;
         /// <summary>
         /// Int key.
         /// </summary>
+        /// When deleting the field, change it to prperty.
+        [Obsolete("Deprecated in API9, Will be removed in API11. Please use IntegerKey instead.")]
+        [SuppressMessage("Microsoft.Design", "CA1051:Do not declare visible instance fields")]
         public int? KeyInt = null;
 
         /// <summary>
         /// String key.
         /// </summary>
+        /// When deleting the field, change it to prperty.
+        [Obsolete("Deprecated in API9, Will be removed in API11. Please use StringKey instead.")]
+        [SuppressMessage("Microsoft.Design", "CA1051:Do not declare visible instance fields")]
         public string KeyString = null;
 
         /// <summary>
         /// True value.
         /// </summary>
+        /// When deleting the field, change it to prperty.
+        [Obsolete("Deprecated in API9, Will be removed in API11. Please use PropertyValue instead.")]
+        [SuppressMessage("Microsoft.Design", "CA1051:Do not declare visible instance fields")]
         public PropertyValue TrueValue = null;
 
         private string _key = null;
@@ -120,10 +132,68 @@ namespace Tizen.NUI
         }
 
         /// <summary>
+        /// Int key.
+        /// </summary>
+        /// When deleting the field, change it to prperty.
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public int? IntegerKey
+        {
+            get
+            {
+                return KeyInt;
+            }
+            set
+            {
+                KeyInt = value;
+            }
+        }
+
+        /// <summary>
+        /// String key.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public string StringKey
+        {
+            get
+            {
+                return KeyString;
+            }
+            set
+            {
+                KeyString = value;
+            }
+        }
+
+        /// <summary>
+        /// Property value.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public PropertyValue PropertyValue
+        {
+            get
+            {
+                return TrueValue;
+            }
+            set
+            {
+                TrueValue = value;
+            }
+        }
+
+        /// <summary>
         /// IntergerValue property.
         /// </summary>
         public int IntergerValue
         {
+            get
+            {
+                if (TrueValue.Get(out int retrivedValue))
+                {
+                    return retrivedValue;
+                }
+                NUILog.Error($"[ERROR] Fail to get IntergerValue from PropertyValue! Return ErrorValue(-1)!");
+                return -1;
+            }
             set
             {
                 TrueValue = new PropertyValue(value);
@@ -135,6 +205,15 @@ namespace Tizen.NUI
         /// </summary>
         public bool BooleanValue
         {
+            get
+            {
+                if (TrueValue.Get(out bool retrivedValue))
+                {
+                    return retrivedValue;
+                }
+                NUILog.Error($"[ERROR] Fail to get BooleanValue from PropertyValue! Return false!");
+                return false;
+            }
             set
             {
                 TrueValue = new PropertyValue(value);
@@ -146,6 +225,15 @@ namespace Tizen.NUI
         /// </summary>
         public float SingleValue
         {
+            get
+            {
+                if (TrueValue.Get(out float retrivedValue))
+                {
+                    return retrivedValue;
+                }
+                NUILog.Error($"[ERROR] Fail to get SingleValue from PropertyValue! Return ErrorValue(-1)!");
+                return -1;
+            }
             set
             {
                 TrueValue = new PropertyValue(value);
@@ -157,6 +245,15 @@ namespace Tizen.NUI
         /// </summary>
         public string StringValue
         {
+            get
+            {
+                if (TrueValue.Get(out string retrivedValue))
+                {
+                    return retrivedValue;
+                }
+                NUILog.Error($"[ERROR] Fail to get SingleValue from PropertyValue! Return ErrorString(error to get StringValue)!");
+                return "error to get StringValue";
+            }
             set
             {
                 TrueValue = new PropertyValue(value);
@@ -168,6 +265,16 @@ namespace Tizen.NUI
         /// </summary>
         public Vector2 Vector2Value
         {
+            get
+            {
+                Vector2 retrivedValue = new Vector2(0, 0);
+                if (TrueValue.Get(retrivedValue))
+                {
+                    return retrivedValue;
+                }
+                NUILog.Error($"[ERROR] Fail to get Vector2Value from PropertyValue!");
+                return retrivedValue;
+            }
             set
             {
                 TrueValue = new PropertyValue(value);
@@ -179,6 +286,16 @@ namespace Tizen.NUI
         /// </summary>
         public Vector3 Vector3Value
         {
+            get
+            {
+                Vector3 retrivedValue = new Vector3(0, 0, 0);
+                if (TrueValue.Get(retrivedValue))
+                {
+                    return retrivedValue;
+                }
+                NUILog.Error($"[ERROR] Fail to get Vector3Value from PropertyValue!");
+                return retrivedValue;
+            }
             set
             {
                 TrueValue = new PropertyValue(value);
@@ -190,6 +307,16 @@ namespace Tizen.NUI
         /// </summary>
         public Vector4 Vector4Value
         {
+            get
+            {
+                Vector4 retrivedValue = new Vector4(0, 0, 0, 0);
+                if (TrueValue.Get(retrivedValue))
+                {
+                    return retrivedValue;
+                }
+                NUILog.Error($"[ERROR] Fail to get Vector4Value from PropertyValue!");
+                return retrivedValue;
+            }
             set
             {
                 TrueValue = new PropertyValue(value);
@@ -201,6 +328,16 @@ namespace Tizen.NUI
         /// </summary>
         public Position PositionValue
         {
+            get
+            {
+                Position retrivedValue = new Position(0, 0, 0);
+                if (TrueValue.Get(retrivedValue))
+                {
+                    return retrivedValue;
+                }
+                NUILog.Error($"[ERROR] Fail to get PositionValue from PropertyValue!");
+                return retrivedValue;
+            }
             set
             {
                 TrueValue = new PropertyValue(value);
@@ -212,6 +349,16 @@ namespace Tizen.NUI
         /// </summary>
         public Position2D Position2DValue
         {
+            get
+            {
+                Position2D retrivedValue = new Position2D(0, 0);
+                if (TrueValue.Get(retrivedValue))
+                {
+                    return retrivedValue;
+                }
+                NUILog.Error($"[ERROR] Fail to get Position2DValue from PropertyValue!");
+                return retrivedValue;
+            }
             set
             {
                 TrueValue = new PropertyValue(value);
@@ -223,6 +370,16 @@ namespace Tizen.NUI
         /// </summary>
         public Size SizeValue
         {
+            get
+            {
+                Size retrivedValue = new Size(0, 0, 0);
+                if (TrueValue.Get(retrivedValue))
+                {
+                    return retrivedValue;
+                }
+                NUILog.Error($"[ERROR] Fail to get SizeValue from PropertyValue!");
+                return retrivedValue;
+            }
             set
             {
                 TrueValue = new PropertyValue(value);
@@ -234,6 +391,16 @@ namespace Tizen.NUI
         /// </summary>
         public Size2D Size2DValue
         {
+            get
+            {
+                Size2D retrivedValue = new Size2D(0, 0);
+                if (TrueValue.Get(retrivedValue))
+                {
+                    return retrivedValue;
+                }
+                NUILog.Error($"[ERROR] Fail to get Size2DValue from PropertyValue!");
+                return retrivedValue;
+            }
             set
             {
                 TrueValue = new PropertyValue(value);
@@ -245,6 +412,16 @@ namespace Tizen.NUI
         /// </summary>
         public Color ColorValue
         {
+            get
+            {
+                Color retrivedValue = new Color(0, 0, 0, 0);
+                if (TrueValue.Get(retrivedValue))
+                {
+                    return retrivedValue;
+                }
+                NUILog.Error($"[ERROR] Fail to get ColorValue from PropertyValue!");
+                return retrivedValue;
+            }
             set
             {
                 TrueValue = new PropertyValue(value);
@@ -256,6 +433,16 @@ namespace Tizen.NUI
         /// </summary>
         public Rectangle RectangleValue
         {
+            get
+            {
+                Rectangle retrivedValue = new Rectangle(0, 0, 0, 0);
+                if (TrueValue.Get(retrivedValue))
+                {
+                    return retrivedValue;
+                }
+                NUILog.Error($"[ERROR] Fail to get RectangleValue from PropertyValue!");
+                return retrivedValue;
+            }
             set
             {
                 TrueValue = new PropertyValue(value);
@@ -267,6 +454,16 @@ namespace Tizen.NUI
         /// </summary>
         public Rotation RotationValue
         {
+            get
+            {
+                Rotation retrivedValue = new Rotation();
+                if (TrueValue.Get(retrivedValue))
+                {
+                    return retrivedValue;
+                }
+                NUILog.Error($"[ERROR] Fail to get RotationValue from PropertyValue!");
+                return retrivedValue;
+            }
             set
             {
                 TrueValue = new PropertyValue(value);
@@ -278,6 +475,16 @@ namespace Tizen.NUI
         /// </summary>
         public RelativeVector2 RelativeVector2Value
         {
+            get
+            {
+                RelativeVector2 retrivedValue = new RelativeVector2(0, 0);
+                if (TrueValue.Get(retrivedValue))
+                {
+                    return retrivedValue;
+                }
+                NUILog.Error($"[ERROR] Fail to get RelativeVector2Value from PropertyValue!");
+                return retrivedValue;
+            }
             set
             {
                 TrueValue = new PropertyValue(value);
@@ -289,6 +496,16 @@ namespace Tizen.NUI
         /// </summary>
         public RelativeVector3 RelativeVector3Value
         {
+            get
+            {
+                RelativeVector3 retrivedValue = new RelativeVector3(0, 0, 0);
+                if (TrueValue.Get(retrivedValue))
+                {
+                    return retrivedValue;
+                }
+                NUILog.Error($"[ERROR] Fail to get RelativeVector3Value from PropertyValue!");
+                return retrivedValue;
+            }
             set
             {
                 TrueValue = new PropertyValue(value);
@@ -300,6 +517,16 @@ namespace Tizen.NUI
         /// </summary>
         public RelativeVector4 RelativeVector4Value
         {
+            get
+            {
+                RelativeVector4 retrivedValue = new RelativeVector4(0, 0, 0, 0);
+                if (TrueValue.Get(retrivedValue))
+                {
+                    return retrivedValue;
+                }
+                NUILog.Error($"[ERROR] Fail to get RelativeVector4Value from PropertyValue!");
+                return retrivedValue;
+            }
             set
             {
                 TrueValue = new PropertyValue(value);
@@ -311,6 +538,16 @@ namespace Tizen.NUI
         /// </summary>
         public Extents ExtentsValue
         {
+            get
+            {
+                Extents retrivedValue = new Extents(0, 0, 0, 0);
+                if (TrueValue.Get(retrivedValue))
+                {
+                    return retrivedValue;
+                }
+                NUILog.Error($"[ERROR] Fail to get ExtentsValue from PropertyValue!");
+                return retrivedValue;
+            }
             set
             {
                 TrueValue = new PropertyValue(value);
@@ -322,6 +559,16 @@ namespace Tizen.NUI
         /// </summary>
         public PropertyArray PropertyArrayValue
         {
+            get
+            {
+                PropertyArray retrivedValue = new PropertyArray();
+                if (TrueValue.Get(retrivedValue))
+                {
+                    return retrivedValue;
+                }
+                NUILog.Error($"[ERROR] Fail to get PropertyArrayValue from PropertyValue!");
+                return retrivedValue;
+            }
             set
             {
                 TrueValue = new PropertyValue(value);
@@ -333,6 +580,16 @@ namespace Tizen.NUI
         /// </summary>
         public PropertyMap PropertyMapValue
         {
+            get
+            {
+                PropertyMap retrivedValue = new PropertyMap();
+                if (TrueValue.Get(retrivedValue))
+                {
+                    return retrivedValue;
+                }
+                NUILog.Error($"[ERROR] Fail to get PropertyMapValue from PropertyValue!");
+                return retrivedValue;
+            }
             set
             {
                 TrueValue = new PropertyValue(value);
@@ -352,5 +609,28 @@ namespace Tizen.NUI
                 KeyString = Key;
             }
         }
+
+
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        protected virtual void Dispose(bool disposing)
+        {
+            if (disposed)
+            {
+                return;
+            }
+
+            if (disposing)
+            {
+                TrueValue?.Dispose();
+            }
+            disposed = true;
+        }
+
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void Dispose()
+        {
+            Dispose(true);
+            global::System.GC.SuppressFinalize(this);
+        }
     }
 }