[NUI] Make BindableObject.IsBound public.
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / XamlBinding / BindableObject.cs
index c7832dd..c656697 100755 (executable)
@@ -45,8 +45,6 @@ namespace Tizen.NUI.Binding
         bool applying;
         object inheritedContext;
 
-        private object bindingContext;
-
         /// <summary>
         /// Gets or sets object that contains the properties that will be targeted by the bound properties that belong to this BindableObject.
         /// </summary>
@@ -94,14 +92,10 @@ namespace Tizen.NUI.Binding
                 {
                     nameToBindableProperty2.TryGetValue(keyValuePair.Key, out var bindableProperty);
 
-                    if (null != bindableProperty && (ChangedPropertiesSet.Contains(bindableProperty) || other.ChangedPropertiesSet.Contains(bindableProperty)))
+                    if (null != bindableProperty && other.IsSet(bindableProperty))
                     {
                         object value = other.GetValue(bindableProperty);
-
-                        if (null != value)
-                        {
-                            InternalSetValue(keyValuePair.Value, value);
-                        }
+                        InternalSetValue(keyValuePair.Value, value);
                     }
                 }
             }
@@ -195,7 +189,7 @@ namespace Tizen.NUI.Binding
             if (property == null)
                 throw new ArgumentNullException(nameof(property));
 
-            if (!IsBinded && property.ValueGetter != null)
+            if (!IsBound && property.ValueGetter != null)
             {
                 return property.ValueGetter(this);
             }
@@ -312,7 +306,7 @@ namespace Tizen.NUI.Binding
 
         internal void InternalSetValue(BindableProperty property, object value)
         {
-            if (true == IsBinded)
+            if (true == IsBound)
             {
                 SetValue(property, value, false, true);
             }
@@ -324,18 +318,12 @@ namespace Tizen.NUI.Binding
                 }
 
                 object oldvalue = null;
-                if (null == property.DefaultValueCreator)
-                {
-                    BindablePropertyContext context = GetOrCreateContext(property);
-                    if (null != context)
-                    {
-                        oldvalue = context.Value;
-                        context.Value = value;
-                    }
-                }
-                else
+                BindablePropertyContext context = GetOrCreateContext(property);
+                if (null != context)
                 {
-                    oldvalue = property.DefaultValueCreator.Invoke(this);
+                    context.Attributes |= BindableContextAttributes.IsManuallySet;
+                    oldvalue = context.Value;
+                    context.Value = value;
                 }
 
                 property.PropertyChanged?.Invoke(this, oldvalue, value);
@@ -343,22 +331,6 @@ namespace Tizen.NUI.Binding
                 OnPropertyChanged(property.PropertyName);
                 OnPropertyChangedWithData(property);
             }
-
-            ChangedPropertiesSet.Add(property);
-        }
-
-        private HashSet<BindableProperty> changedPropertiesSet;
-        private HashSet<BindableProperty> ChangedPropertiesSet
-        {
-            get
-            {
-                if (null == changedPropertiesSet)
-                {
-                    changedPropertiesSet = new HashSet<BindableProperty>();
-                }
-
-                return changedPropertiesSet;
-            }
         }
 
         private HashSet<BindableProperty> changedPropertiesSetExcludingStyle;
@@ -645,7 +617,7 @@ namespace Tizen.NUI.Binding
             if (fromStyle && !CanBeSetFromStyle(targetProperty))
                 return;
 
-            IsBinded = true;
+            IsBound = true;
 
             var context = GetOrCreateContext(targetProperty);
             if (fromStyle)
@@ -819,7 +791,11 @@ namespace Tizen.NUI.Binding
             }
         }
 
-        internal bool IsBinded
+        /// <summary>
+        /// Check if object is bound or not.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool IsBound
         {
             get;
             set;
@@ -833,7 +809,7 @@ namespace Tizen.NUI.Binding
 
             if (newvalue is BindableObject targetBindableObject)
             {
-                targetBindableObject.IsBinded = true;
+                targetBindableObject.IsBound = true;
             }
         }