2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Diagnostics;
5 using System.Reflection;
6 using System.Runtime.CompilerServices;
7 using Tizen.NUI.Binding.Internals;
9 namespace Tizen.NUI.Binding
12 /// Provides a mechanism by which application developers can propagate changes that are made to data in one object to another, by enabling validation, type coercion, and an event system.
14 [EditorBrowsable(EditorBrowsableState.Never)]
15 public abstract class BindableObject : INotifyPropertyChanged, IDynamicResourceHandler
18 /// Implements the bound property whose interface is provided by the BindingContext property.
20 internal static readonly BindableProperty BindingContextProperty =
21 BindableProperty.Create("BindingContext", typeof(object), typeof(BindableObject), default(object),
22 BindingMode.OneWay, null, BindingContextPropertyChanged, null, null, BindingContextPropertyBindingChanging);
24 readonly List<BindablePropertyContext> _properties = new List<BindablePropertyContext>(4);
27 object _inheritedContext;
30 /// Gets or sets object that contains the properties that will be targeted by the bound properties that belong to this BindableObject.
32 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
33 [EditorBrowsable(EditorBrowsableState.Never)]
34 public object BindingContext
36 get { return _inheritedContext ?? GetValue(BindingContextProperty); }
37 set { SetValue(BindingContextProperty, value); }
40 void IDynamicResourceHandler.SetDynamicResource(BindableProperty property, string key)
42 SetDynamicResource(property, key, false);
46 /// Raised when a property has changed.
48 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
49 [EditorBrowsable(EditorBrowsableState.Never)]
50 public event PropertyChangedEventHandler PropertyChanged;
53 /// Raised whenever the BindingContext property changes.
55 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
56 [EditorBrowsable(EditorBrowsableState.Never)]
57 public event EventHandler BindingContextChanged;
59 internal void ClearValue(BindableProperty property, bool fromStyle)
61 ClearValue(property, fromStyle: fromStyle, checkAccess: true);
65 /// Clears any value set by Xamarin.Forms.BindableObject.SetValue.
67 /// <param name="property">The BindableProperty to clear</param>
68 internal void ClearValue(BindableProperty property)
70 ClearValue(property, fromStyle: false, checkAccess: true);
74 /// Clears any value set by Xamarin.Forms.BindableObject.SetValue for the property that is identified by propertyKey.
76 /// <param name="propertyKey">The BindablePropertyKey that identifies the BindableProperty to clear.</param>
77 internal void ClearValue(BindablePropertyKey propertyKey)
79 if (propertyKey == null)
80 throw new ArgumentNullException("propertyKey");
82 ClearValue(propertyKey.BindableProperty, fromStyle:false, checkAccess: false);
86 /// Return true if the target property exists and has been set.
88 /// <param name="targetProperty">The target property</param>
89 /// <returns>return true if the target property exists and has been set</returns>
90 internal bool IsSet(BindableProperty targetProperty)
92 if (targetProperty == null)
93 throw new ArgumentNullException(nameof(targetProperty));
95 var bpcontext = GetContext(targetProperty);
96 return bpcontext != null
97 && (bpcontext.Attributes & BindableContextAttributes.IsDefaultValue) == 0;
101 /// Returns the value that is contained the BindableProperty.
103 /// <param name="property">The BindableProperty for which to get the value.</param>
104 /// <returns>The value that is contained the BindableProperty</returns>
105 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
106 [EditorBrowsable(EditorBrowsableState.Never)]
107 public object GetValue(BindableProperty property)
109 if (property == null)
110 throw new ArgumentNullException("property");
112 BindablePropertyContext context = property.DefaultValueCreator != null ? GetOrCreateContext(property) : GetContext(property);
115 return property.DefaultValue;
117 return context.Value;
121 /// Raised when a property is about to change.
123 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
124 [EditorBrowsable(EditorBrowsableState.Never)]
125 public event PropertyChangingEventHandler PropertyChanging;
128 /// Removes a previously set binding.
130 /// <param name="property">The BindableProperty from which to remove bindings.</param>
131 internal void RemoveBinding(BindableProperty property)
133 if (property == null)
134 throw new ArgumentNullException("property");
136 BindablePropertyContext context = GetContext(property);
137 if (context == null || context.Binding == null)
140 RemoveBinding(property, context);
144 /// Assigns a binding to a property.
146 /// <param name="targetProperty">The BindableProperty on which to set a binding.</param>
147 /// <param name="binding">The binding to set.</param>
148 internal void SetBinding(BindableProperty targetProperty, BindingBase binding)
150 SetBinding(targetProperty, binding, false);
153 private bool isCreateByXaml = false;
154 internal virtual bool IsCreateByXaml
158 return isCreateByXaml;
162 isCreateByXaml = value;
167 /// Sets the value of the specified property.
169 /// <param name="property">The BindableProperty on which to assign a value.</param>
170 /// <param name="value">The value to set.</param>
171 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
172 [EditorBrowsable(EditorBrowsableState.Never)]
173 public void SetValue(BindableProperty property, object value)
175 if (true == isCreateByXaml)
177 SetValue(property, value, false, true);
181 property.PropertyChanged?.Invoke(this, null, value);
185 internal void SetValueAndForceSendChangeSignal(BindableProperty property, object value)
187 if (property == null)
188 throw new ArgumentNullException("property");
190 if (true == isCreateByXaml)
192 if (property.IsReadOnly)
193 throw new InvalidOperationException(string.Format("The BindableProperty \"{0}\" is readonly.", property.PropertyName));
195 SetValueCore(property, value, SetValueFlags.ClearOneWayBindings | SetValueFlags.ClearDynamicResource,
196 SetValuePrivateFlags.ManuallySet | SetValuePrivateFlags.CheckAccess, true);
200 property.PropertyChanged?.Invoke(this, null, value);
205 /// Sets the value of the propertyKey.
207 /// <param name="propertyKey">The BindablePropertyKey on which to assign a value.</param>
208 /// <param name="value">The value to set.</param>
209 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
210 [EditorBrowsable(EditorBrowsableState.Never)]
211 public void SetValue(BindablePropertyKey propertyKey, object value)
213 if (propertyKey == null)
214 throw new ArgumentNullException("propertyKey");
216 SetValue(propertyKey.BindableProperty, value, false, false);
220 /// Set the inherited context to a neated element.
222 /// <param name="bindable">The object on which to set the inherited binding context.</param>
223 /// <param name="value">The inherited context to set.</param>
224 [EditorBrowsable(EditorBrowsableState.Never)]
225 public static void SetInheritedBindingContext(BindableObject bindable, object value)
227 BindablePropertyContext bpContext = bindable.GetContext(BindingContextProperty);
228 if (bpContext != null && ((bpContext.Attributes & BindableContextAttributes.IsManuallySet) != 0))
231 object oldContext = bindable._inheritedContext;
233 if (ReferenceEquals(oldContext, value))
236 if (bpContext != null && oldContext == null)
237 oldContext = bpContext.Value;
239 if (bpContext != null && bpContext.Binding != null)
241 bpContext.Binding.Context = value;
242 bindable._inheritedContext = null;
246 bindable._inheritedContext = value;
249 bindable.ApplyBindings(skipBindingContext:false, fromBindingContextChanged:true);
250 bindable.OnBindingContextChanged();
254 /// Apply the bindings to BindingContext.
256 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
257 [EditorBrowsable(EditorBrowsableState.Never)]
258 protected void ApplyBindings()
260 ApplyBindings(skipBindingContext: false, fromBindingContextChanged: false);
264 /// Override this method to execute an action when the BindingContext changes.
266 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
267 [EditorBrowsable(EditorBrowsableState.Never)]
268 protected virtual void OnBindingContextChanged()
270 BindingContextChanged?.Invoke(this, EventArgs.Empty);
274 /// Call this method from a child class to notify that a change happened on a property.
276 /// <param name="propertyName">The name of the property that changed.</param>
277 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
278 [EditorBrowsable(EditorBrowsableState.Never)]
279 protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
280 => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
283 /// Call this method from a child class to notify that a change is going to happen on a property.
285 /// <param name="propertyName">The name of the property that is changing.</param>
286 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
287 [EditorBrowsable(EditorBrowsableState.Never)]
288 protected virtual void OnPropertyChanging([CallerMemberName] string propertyName = null)
289 => PropertyChanging?.Invoke(this, new PropertyChangingEventArgs(propertyName));
292 /// Unapplies all previously set bindings.
294 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
295 [EditorBrowsable(EditorBrowsableState.Never)]
296 protected void UnapplyBindings()
298 for (int i = 0, _propertiesCount = _properties.Count; i < _propertiesCount; i++) {
299 BindablePropertyContext context = _properties [i];
300 if (context.Binding == null)
303 context.Binding.Unapply();
307 internal bool GetIsBound(BindableProperty targetProperty)
309 if (targetProperty == null)
310 throw new ArgumentNullException("targetProperty");
312 BindablePropertyContext bpcontext = GetContext(targetProperty);
313 return bpcontext != null && bpcontext.Binding != null;
317 /// Returns the value that is contained the BindableProperty.
319 /// <param name="property0">The BindableProperty instance.</param>
320 /// <param name="property1">The BindableProperty instance.</param>
321 /// <returns>The value that is contained the BindableProperty</returns>
322 internal object[] GetValues(BindableProperty property0, BindableProperty property1)
324 var values = new object[2];
326 for (var i = 0; i < _properties.Count; i++)
328 BindablePropertyContext context = _properties[i];
330 if (ReferenceEquals(context.Property, property0))
332 values[0] = context.Value;
335 else if (ReferenceEquals(context.Property, property1))
337 values[1] = context.Value;
341 if (property0 == null && property1 == null)
345 if (!ReferenceEquals(property0, null))
346 values[0] = property0.DefaultValueCreator == null ? property0.DefaultValue : CreateAndAddContext(property0).Value;
347 if (!ReferenceEquals(property1, null))
348 values[1] = property1.DefaultValueCreator == null ? property1.DefaultValue : CreateAndAddContext(property1).Value;
354 /// Returns the value that is contained the BindableProperty.
356 /// <param name="property0">The BindableProperty instance.</param>
357 /// <param name="property1">The BindableProperty instance.</param>
358 /// <param name="property2">The BindableProperty instance.</param>
359 /// <returns>The value that is contained the BindableProperty</returns>
360 internal object[] GetValues(BindableProperty property0, BindableProperty property1, BindableProperty property2)
362 var values = new object[3];
364 for (var i = 0; i < _properties.Count; i++)
366 BindablePropertyContext context = _properties[i];
368 if (ReferenceEquals(context.Property, property0))
370 values[0] = context.Value;
373 else if (ReferenceEquals(context.Property, property1))
375 values[1] = context.Value;
378 else if (ReferenceEquals(context.Property, property2))
380 values[2] = context.Value;
384 if (property0 == null && property1 == null && property2 == null)
388 if (!ReferenceEquals(property0, null))
389 values[0] = property0.DefaultValueCreator == null ? property0.DefaultValue : CreateAndAddContext(property0).Value;
390 if (!ReferenceEquals(property1, null))
391 values[1] = property1.DefaultValueCreator == null ? property1.DefaultValue : CreateAndAddContext(property1).Value;
392 if (!ReferenceEquals(property2, null))
393 values[2] = property2.DefaultValueCreator == null ? property2.DefaultValue : CreateAndAddContext(property2).Value;
399 /// Returns the value that is contained the BindableProperty.
401 /// <param name="properties">The array of the BindableProperty instances</param>
402 /// <returns>The values that is contained the BindableProperty instances.</returns>
403 internal object[] GetValues(params BindableProperty[] properties)
405 var values = new object[properties.Length];
406 for (var i = 0; i < _properties.Count; i++) {
407 var context = _properties[i];
408 var index = properties.IndexOf(context.Property);
411 values[index] = context.Value;
413 for (var i = 0; i < values.Length; i++) {
414 if (!ReferenceEquals(values[i], null))
416 values[i] = properties[i].DefaultValueCreator == null ? properties[i].DefaultValue : CreateAndAddContext(properties[i]).Value;
421 internal virtual void OnRemoveDynamicResource(BindableProperty property)
425 internal virtual void OnSetDynamicResource(BindableProperty property, string key)
429 internal void RemoveDynamicResource(BindableProperty property)
431 if (property == null)
432 throw new ArgumentNullException("property");
434 OnRemoveDynamicResource(property);
435 BindablePropertyContext context = GetOrCreateContext(property);
436 context.Attributes &= ~BindableContextAttributes.IsDynamicResource;
439 internal void SetBinding(BindableProperty targetProperty, BindingBase binding, bool fromStyle)
441 if (targetProperty == null)
442 throw new ArgumentNullException("targetProperty");
444 throw new ArgumentNullException("binding");
446 if (fromStyle && !CanBeSetFromStyle(targetProperty))
449 var context = GetOrCreateContext(targetProperty);
451 context.Attributes |= BindableContextAttributes.IsSetFromStyle;
453 context.Attributes &= ~BindableContextAttributes.IsSetFromStyle;
455 if (context.Binding != null)
456 context.Binding.Unapply();
458 BindingBase oldBinding = context.Binding;
459 context.Binding = binding;
461 targetProperty.BindingChanging?.Invoke(this, oldBinding, binding);
463 binding.Apply(BindingContext, this, targetProperty);
466 bool CanBeSetFromStyle(BindableProperty property)
468 var context = GetContext(property);
471 if ((context.Attributes & BindableContextAttributes.IsSetFromStyle) == BindableContextAttributes.IsSetFromStyle)
473 if ((context.Attributes & BindableContextAttributes.IsDefaultValue) == BindableContextAttributes.IsDefaultValue)
475 if ((context.Attributes & BindableContextAttributes.IsDefaultValueCreated) == BindableContextAttributes.IsDefaultValueCreated)
480 internal void SetDynamicResource(BindableProperty property, string key)
482 SetDynamicResource(property, key, false);
485 internal void SetDynamicResource(BindableProperty property, string key, bool fromStyle)
487 if (property == null)
488 throw new ArgumentNullException(nameof(property));
489 if (string.IsNullOrEmpty(key))
490 throw new ArgumentNullException(nameof(key));
491 if (fromStyle && !CanBeSetFromStyle(property))
494 var context = GetOrCreateContext(property);
496 context.Attributes |= BindableContextAttributes.IsDynamicResource;
498 context.Attributes |= BindableContextAttributes.IsSetFromStyle;
500 context.Attributes &= ~BindableContextAttributes.IsSetFromStyle;
502 OnSetDynamicResource(property, key);
505 internal void SetValue(BindableProperty property, object value, bool fromStyle)
507 SetValue(property, value, fromStyle, true);
510 internal void SetValueCore(BindablePropertyKey propertyKey, object value, SetValueFlags attributes = SetValueFlags.None)
512 SetValueCore(propertyKey.BindableProperty, value, attributes, SetValuePrivateFlags.None, false);
516 /// For internal use.
518 /// <param name="property">The BindableProperty on which to assign a value.</param>
519 /// <param name="value">The value to set</param>
520 /// <param name="attributes">The set value flag</param>
521 [EditorBrowsable(EditorBrowsableState.Never)]
522 internal void SetValueCore(BindableProperty property, object value, SetValueFlags attributes = SetValueFlags.None)
524 SetValueCore(property, value, attributes, SetValuePrivateFlags.Default, false);
527 internal void SetValueCore(BindableProperty property, object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes, bool forceSendChangeSignal)
529 bool checkAccess = (privateAttributes & SetValuePrivateFlags.CheckAccess) != 0;
530 bool manuallySet = (privateAttributes & SetValuePrivateFlags.ManuallySet) != 0;
531 bool silent = (privateAttributes & SetValuePrivateFlags.Silent) != 0;
532 bool fromStyle = (privateAttributes & SetValuePrivateFlags.FromStyle) != 0;
533 bool converted = (privateAttributes & SetValuePrivateFlags.Converted) != 0;
535 if (property == null)
536 throw new ArgumentNullException("property");
537 if (checkAccess && property.IsReadOnly)
539 Debug.WriteLine("Can not set the BindableProperty \"{0}\" because it is readonly.", property.PropertyName);
543 if (!converted && !property.TryConvert(ref value))
545 Console.WriteLine("SetValue", "Can not convert {0} to type '{1}'", value, property.ReturnType);
549 if (property.ValidateValue != null && !property.ValidateValue(this, value))
550 throw new ArgumentException("Value was an invalid value for " + property.PropertyName, "value");
552 if (property.CoerceValue != null)
553 value = property.CoerceValue(this, value);
555 BindablePropertyContext context = GetOrCreateContext(property);
557 context.Attributes |= BindableContextAttributes.IsManuallySet;
558 context.Attributes &= ~BindableContextAttributes.IsSetFromStyle;
560 context.Attributes &= ~BindableContextAttributes.IsManuallySet;
563 context.Attributes |= BindableContextAttributes.IsSetFromStyle;
564 // else omitted on purpose
566 bool currentlyApplying = _applying;
568 if ((context.Attributes & BindableContextAttributes.IsBeingSet) != 0)
570 Queue<SetValueArgs> delayQueue = context.DelayedSetters;
571 if (delayQueue == null)
572 context.DelayedSetters = delayQueue = new Queue<SetValueArgs>();
574 delayQueue.Enqueue(new SetValueArgs(property, context, value, currentlyApplying, attributes));
578 context.Attributes |= BindableContextAttributes.IsBeingSet;
579 SetValueActual(property, context, value, currentlyApplying, forceSendChangeSignal, attributes, silent);
581 Queue<SetValueArgs> delayQueue = context.DelayedSetters;
582 if (delayQueue != null)
584 while (delayQueue.Count > 0)
586 SetValueArgs s = delayQueue.Dequeue();
587 SetValueActual(s.Property, s.Context, s.Value, s.CurrentlyApplying, forceSendChangeSignal, s.Attributes);
590 context.DelayedSetters = null;
593 context.Attributes &= ~BindableContextAttributes.IsBeingSet;
597 internal void ApplyBindings(bool skipBindingContext, bool fromBindingContextChanged)
599 var prop = _properties.ToArray();
600 for (int i = 0, propLength = prop.Length; i < propLength; i++) {
601 BindablePropertyContext context = prop [i];
602 BindingBase binding = context.Binding;
606 if (skipBindingContext && ReferenceEquals(context.Property, BindingContextProperty))
609 binding.Unapply(fromBindingContextChanged: fromBindingContextChanged);
610 binding.Apply(BindingContext, this, context.Property, fromBindingContextChanged: fromBindingContextChanged);
614 static void BindingContextPropertyBindingChanging(BindableObject bindable, BindingBase oldBindingBase, BindingBase newBindingBase)
616 object context = bindable._inheritedContext;
617 var oldBinding = oldBindingBase as Binding;
618 var newBinding = newBindingBase as Binding;
620 if (context == null && oldBinding != null)
621 context = oldBinding.Context;
622 if (context != null && newBinding != null)
623 newBinding.Context = context;
626 static void BindingContextPropertyChanged(BindableObject bindable, object oldvalue, object newvalue)
628 bindable._inheritedContext = null;
629 bindable.ApplyBindings(skipBindingContext: true, fromBindingContextChanged:true);
630 bindable.OnBindingContextChanged();
633 void ClearValue(BindableProperty property, bool fromStyle, bool checkAccess)
635 if (property == null)
636 throw new ArgumentNullException(nameof(property));
638 if (checkAccess && property.IsReadOnly)
639 throw new InvalidOperationException(string.Format("The BindableProperty \"{0}\" is readonly.", property.PropertyName));
641 BindablePropertyContext bpcontext = GetContext(property);
642 if (bpcontext == null)
645 if (fromStyle && !CanBeSetFromStyle(property))
648 object original = bpcontext.Value;
650 object newValue = property.GetDefaultValue(this);
652 bool same = Equals(original, newValue);
655 property.PropertyChanging?.Invoke(this, original, newValue);
657 OnPropertyChanging(property.PropertyName);
660 bpcontext.Attributes &= ~BindableContextAttributes.IsManuallySet;
661 bpcontext.Value = newValue;
662 if (property.DefaultValueCreator == null)
663 bpcontext.Attributes |= BindableContextAttributes.IsDefaultValue;
665 bpcontext.Attributes |= BindableContextAttributes.IsDefaultValueCreated;
669 OnPropertyChanged(property.PropertyName);
670 property.PropertyChanged?.Invoke(this, original, newValue);
674 [MethodImpl(MethodImplOptions.AggressiveInlining)]
675 BindablePropertyContext CreateAndAddContext(BindableProperty property)
677 var context = new BindablePropertyContext { Property = property, Value = property.DefaultValueCreator != null ? property.DefaultValueCreator(this) : property.DefaultValue };
679 if (property.DefaultValueCreator == null)
680 context.Attributes = BindableContextAttributes.IsDefaultValue;
682 context.Attributes = BindableContextAttributes.IsDefaultValueCreated;
684 _properties.Add(context);
688 [MethodImpl(MethodImplOptions.AggressiveInlining)]
689 BindablePropertyContext GetContext(BindableProperty property)
691 List<BindablePropertyContext> properties = _properties;
693 for (var i = 0; i < properties.Count; i++)
695 BindablePropertyContext context = properties[i];
696 if (ReferenceEquals(context.Property, property))
703 [MethodImpl(MethodImplOptions.AggressiveInlining)]
704 BindablePropertyContext GetOrCreateContext(BindableProperty property)
706 BindablePropertyContext context = GetContext(property);
709 context = CreateAndAddContext(property);
711 else if (property.DefaultValueCreator != null )
713 context.Value = property.DefaultValueCreator(this); //Update Value from dali
719 void RemoveBinding(BindableProperty property, BindablePropertyContext context)
721 context.Binding.Unapply();
723 property.BindingChanging?.Invoke(this, context.Binding, null);
725 context.Binding = null;
728 void SetValue(BindableProperty property, object value, bool fromStyle, bool checkAccess)
730 if (property == null)
731 throw new ArgumentNullException("property");
733 if (checkAccess && property.IsReadOnly)
734 throw new InvalidOperationException(string.Format("The BindableProperty \"{0}\" is readonly.", property.PropertyName));
736 if (fromStyle && !CanBeSetFromStyle(property))
739 SetValueCore(property, value, SetValueFlags.ClearOneWayBindings | SetValueFlags.ClearDynamicResource,
740 (fromStyle ? SetValuePrivateFlags.FromStyle : SetValuePrivateFlags.ManuallySet) | (checkAccess ? SetValuePrivateFlags.CheckAccess : 0),
744 void SetValueActual(BindableProperty property, BindablePropertyContext context, object value, bool currentlyApplying, bool forceSendChangeSignal, SetValueFlags attributes, bool silent = false)
746 object original = context.Value;
747 bool raiseOnEqual = (attributes & SetValueFlags.RaiseOnEqual) != 0;
748 bool clearDynamicResources = (attributes & SetValueFlags.ClearDynamicResource) != 0;
749 bool clearOneWayBindings = (attributes & SetValueFlags.ClearOneWayBindings) != 0;
750 bool clearTwoWayBindings = (attributes & SetValueFlags.ClearTwoWayBindings) != 0;
752 bool same = ReferenceEquals(context.Property, BindingContextProperty) ? ReferenceEquals(value, original) : Equals(value, original);
753 if (!silent && (!same || raiseOnEqual))
755 property.PropertyChanging?.Invoke(this, original, value);
757 OnPropertyChanging(property.PropertyName);
760 if (!same || raiseOnEqual)
762 context.Value = value;
765 context.Attributes &= ~BindableContextAttributes.IsDefaultValue;
766 context.Attributes &= ~BindableContextAttributes.IsDefaultValueCreated;
768 if ((context.Attributes & BindableContextAttributes.IsDynamicResource) != 0 && clearDynamicResources)
769 RemoveDynamicResource(property);
771 BindingBase binding = context.Binding;
774 if (clearOneWayBindings && binding.GetRealizedMode(property) == BindingMode.OneWay || clearTwoWayBindings && binding.GetRealizedMode(property) == BindingMode.TwoWay)
776 RemoveBinding(property, context);
783 if ((!same || raiseOnEqual))
785 property.PropertyChanged?.Invoke(this, original, value);
787 if (binding != null && !currentlyApplying)
794 OnPropertyChanged(property.PropertyName);
796 else if (true == same && true == forceSendChangeSignal)
798 if (binding != null && !currentlyApplying)
805 OnPropertyChanged(property.PropertyName);
811 enum BindableContextAttributes
813 IsManuallySet = 1 << 0,
815 IsDynamicResource = 1 << 2,
816 IsSetFromStyle = 1 << 3,
817 IsDefaultValue = 1 << 4,
818 IsDefaultValueCreated = 1 << 5,
821 class BindablePropertyContext
823 public BindableContextAttributes Attributes;
824 public BindingBase Binding;
825 public Queue<SetValueArgs> DelayedSetters;
826 public BindableProperty Property;
831 internal enum SetValuePrivateFlags
834 CheckAccess = 1 << 0,
836 ManuallySet = 1 << 2,
839 Default = CheckAccess
844 public readonly SetValueFlags Attributes;
845 public readonly BindablePropertyContext Context;
846 public readonly bool CurrentlyApplying;
847 public readonly BindableProperty Property;
848 public readonly object Value;
850 public SetValueArgs(BindableProperty property, BindablePropertyContext context, object value, bool currentlyApplying, SetValueFlags attributes)
855 CurrentlyApplying = currentlyApplying;
856 Attributes = attributes;
862 namespace Tizen.NUI.Binding.Internals
865 /// SetValueFlags. For internal use.
868 [EditorBrowsable(EditorBrowsableState.Never)]
869 public enum SetValueFlags
874 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
875 [EditorBrowsable(EditorBrowsableState.Never)]
879 /// Clear OneWay bindings.
881 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
882 [EditorBrowsable(EditorBrowsableState.Never)]
883 ClearOneWayBindings = 1 << 0,
886 /// Clear TwoWay bindings.
888 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
889 [EditorBrowsable(EditorBrowsableState.Never)]
890 ClearTwoWayBindings = 1 << 1,
893 /// Clear dynamic resource.
895 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
896 [EditorBrowsable(EditorBrowsableState.Never)]
897 ClearDynamicResource = 1 << 2,
902 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
903 [EditorBrowsable(EditorBrowsableState.Never)]
904 RaiseOnEqual = 1 << 3