[NUI]Add xaml support for nui and nui xaml test sample (#230)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / XamlBinding / BindableObject.cs
1 using System;
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.Internals;
8
9 namespace Tizen.NUI.Binding
10 {
11         public abstract class BindableObject : INotifyPropertyChanged, IDynamicResourceHandler
12         {
13                 public static readonly BindableProperty BindingContextProperty =
14                         BindableProperty.Create("BindingContext", typeof(object), typeof(BindableObject), default(object),
15                                                                         BindingMode.OneWay, null, BindingContextPropertyChanged, null, null, BindingContextPropertyBindingChanging);
16
17                 readonly List<BindablePropertyContext> _properties = new List<BindablePropertyContext>(4);
18
19                 bool _applying;
20                 object _inheritedContext;
21
22                 public object BindingContext
23                 {
24                         get { return _inheritedContext ?? GetValue(BindingContextProperty); }
25                         set { SetValue(BindingContextProperty, value); }
26                 }
27
28                 void IDynamicResourceHandler.SetDynamicResource(BindableProperty property, string key)
29                 {
30                         SetDynamicResource(property, key, false);
31                 }
32
33                 public event PropertyChangedEventHandler PropertyChanged;
34
35                 public event EventHandler BindingContextChanged;
36
37                 internal void ClearValue(BindableProperty property, bool fromStyle)
38                 {
39                         ClearValue(property, fromStyle: fromStyle, checkAccess: true);
40                 }
41
42                 public void ClearValue(BindableProperty property)
43                 {
44                         ClearValue(property, fromStyle: false, checkAccess: true);
45                 }
46
47                 public void ClearValue(BindablePropertyKey propertyKey)
48                 {
49                         if (propertyKey == null)
50                                 throw new ArgumentNullException("propertyKey");
51
52                         ClearValue(propertyKey.BindableProperty, fromStyle:false, checkAccess: false);
53                 }
54
55                 public bool IsSet(BindableProperty targetProperty)
56                 {
57                         if (targetProperty == null)
58                                 throw new ArgumentNullException(nameof(targetProperty));
59
60                         var bpcontext = GetContext(targetProperty);
61                         return bpcontext != null
62                                 && (bpcontext.Attributes & BindableContextAttributes.IsDefaultValue) == 0;
63                 }
64
65                 public object GetValue(BindableProperty property)
66                 {
67                         if (property == null)
68                                 throw new ArgumentNullException("property");
69
70                         BindablePropertyContext context = property.DefaultValueCreator != null ? GetOrCreateContext(property) : GetContext(property);
71
72                         if (context == null)
73                                 return property.DefaultValue;
74
75                         return context.Value;
76                 }
77
78                 public event PropertyChangingEventHandler PropertyChanging;
79
80                 public void RemoveBinding(BindableProperty property)
81                 {
82                         if (property == null)
83                                 throw new ArgumentNullException("property");
84
85                         BindablePropertyContext context = GetContext(property);
86                         if (context == null || context.Binding == null)
87                                 return;
88
89                         RemoveBinding(property, context);
90                 }
91
92                 public void SetBinding(BindableProperty targetProperty, BindingBase binding)
93                 {
94                         SetBinding(targetProperty, binding, false);
95                 }
96
97                 public void SetValue(BindableProperty property, object value)
98                 {
99                         SetValue(property, value, false, true);
100                 }
101
102                 public void SetValue(BindablePropertyKey propertyKey, object value)
103                 {
104                         if (propertyKey == null)
105                                 throw new ArgumentNullException("propertyKey");
106
107                         SetValue(propertyKey.BindableProperty, value, false, false);
108                 }
109
110                 [EditorBrowsable(EditorBrowsableState.Never)]
111                 public static void SetInheritedBindingContext(BindableObject bindable, object value)
112                 {
113                         BindablePropertyContext bpContext = bindable.GetContext(BindingContextProperty);
114                         if (bpContext != null && ((bpContext.Attributes & BindableContextAttributes.IsManuallySet) != 0))
115                                 return;
116
117                         object oldContext = bindable._inheritedContext;
118
119                         if (ReferenceEquals(oldContext, value))
120                                 return;
121
122                         if (bpContext != null && oldContext == null)
123                                 oldContext = bpContext.Value;
124
125                         if (bpContext != null && bpContext.Binding != null)
126                         {
127                                 bpContext.Binding.Context = value;
128                                 bindable._inheritedContext = null;
129                         }
130                         else
131                         {
132                                 bindable._inheritedContext = value;
133                         }
134
135                         bindable.ApplyBindings(skipBindingContext:false, fromBindingContextChanged:true);
136                         bindable.OnBindingContextChanged();
137                 }
138
139                 protected void ApplyBindings()
140                 {
141                         ApplyBindings(skipBindingContext: false, fromBindingContextChanged: false);
142                 }
143
144                 protected virtual void OnBindingContextChanged()
145                 {
146                         BindingContextChanged?.Invoke(this, EventArgs.Empty);
147                 }
148
149                 protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
150                         => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
151
152                 protected virtual void OnPropertyChanging([CallerMemberName] string propertyName = null)
153                         => PropertyChanging?.Invoke(this, new PropertyChangingEventArgs(propertyName));
154
155                 protected void UnapplyBindings()
156                 {
157                         for (int i = 0, _propertiesCount = _properties.Count; i < _propertiesCount; i++) {
158                                 BindablePropertyContext context = _properties [i];
159                                 if (context.Binding == null)
160                                         continue;
161
162                                 context.Binding.Unapply();
163                         }
164                 }
165
166                 internal bool GetIsBound(BindableProperty targetProperty)
167                 {
168                         if (targetProperty == null)
169                                 throw new ArgumentNullException("targetProperty");
170
171                         BindablePropertyContext bpcontext = GetContext(targetProperty);
172                         return bpcontext != null && bpcontext.Binding != null;
173                 }
174
175                 [EditorBrowsable(EditorBrowsableState.Never)]
176                 public object[] GetValues(BindableProperty property0, BindableProperty property1)
177                 {
178                         var values = new object[2];
179
180                         for (var i = 0; i < _properties.Count; i++)
181                         {
182                                 BindablePropertyContext context = _properties[i];
183
184                                 if (ReferenceEquals(context.Property, property0))
185                                 {
186                                         values[0] = context.Value;
187                                         property0 = null;
188                                 }
189                                 else if (ReferenceEquals(context.Property, property1))
190                                 {
191                                         values[1] = context.Value;
192                                         property1 = null;
193                                 }
194
195                                 if (property0 == null && property1 == null)
196                                         return values;
197                         }
198
199                         if (!ReferenceEquals(property0, null))
200                                 values[0] = property0.DefaultValueCreator == null ? property0.DefaultValue : CreateAndAddContext(property0).Value;
201                         if (!ReferenceEquals(property1, null))
202                                 values[1] = property1.DefaultValueCreator == null ? property1.DefaultValue : CreateAndAddContext(property1).Value;
203
204                         return values;
205                 }
206
207                 [EditorBrowsable(EditorBrowsableState.Never)]
208                 public object[] GetValues(BindableProperty property0, BindableProperty property1, BindableProperty property2)
209                 {
210                         var values = new object[3];
211
212                         for (var i = 0; i < _properties.Count; i++)
213                         {
214                                 BindablePropertyContext context = _properties[i];
215
216                                 if (ReferenceEquals(context.Property, property0))
217                                 {
218                                         values[0] = context.Value;
219                                         property0 = null;
220                                 }
221                                 else if (ReferenceEquals(context.Property, property1))
222                                 {
223                                         values[1] = context.Value;
224                                         property1 = null;
225                                 }
226                                 else if (ReferenceEquals(context.Property, property2))
227                                 {
228                                         values[2] = context.Value;
229                                         property2 = null;
230                                 }
231
232                                 if (property0 == null && property1 == null && property2 == null)
233                                         return values;
234                         }
235
236                         if (!ReferenceEquals(property0, null))
237                                 values[0] = property0.DefaultValueCreator == null ? property0.DefaultValue : CreateAndAddContext(property0).Value;
238                         if (!ReferenceEquals(property1, null))
239                                 values[1] = property1.DefaultValueCreator == null ? property1.DefaultValue : CreateAndAddContext(property1).Value;
240                         if (!ReferenceEquals(property2, null))
241                                 values[2] = property2.DefaultValueCreator == null ? property2.DefaultValue : CreateAndAddContext(property2).Value;
242
243                         return values;
244                 }
245
246                 [EditorBrowsable(EditorBrowsableState.Never)]
247                 internal object[] GetValues(params BindableProperty[] properties)
248                 {
249                         var values = new object[properties.Length];
250                         for (var i = 0; i < _properties.Count; i++) {
251                                 var context = _properties[i];
252                                 var index = properties.IndexOf(context.Property);
253                                 if (index < 0)
254                                         continue;
255                                 values[index] = context.Value;
256                         }
257                         for (var i = 0; i < values.Length; i++) {
258                                 if (!ReferenceEquals(values[i], null))
259                                         continue;
260                                 values[i] = properties[i].DefaultValueCreator == null ? properties[i].DefaultValue : CreateAndAddContext(properties[i]).Value;
261                         }
262                         return values;
263                 }
264
265                 internal virtual void OnRemoveDynamicResource(BindableProperty property)
266                 {
267                 }
268
269                 internal virtual void OnSetDynamicResource(BindableProperty property, string key)
270                 {
271                 }
272
273                 internal void RemoveDynamicResource(BindableProperty property)
274                 {
275                         if (property == null)
276                                 throw new ArgumentNullException("property");
277
278                         OnRemoveDynamicResource(property);
279                         BindablePropertyContext context = GetOrCreateContext(property);
280                         context.Attributes &= ~BindableContextAttributes.IsDynamicResource;
281                 }
282
283                 internal void SetBinding(BindableProperty targetProperty, BindingBase binding, bool fromStyle)
284                 {
285                         if (targetProperty == null)
286                                 throw new ArgumentNullException("targetProperty");
287                         if (binding == null)
288                                 throw new ArgumentNullException("binding");
289
290                         if (fromStyle && !CanBeSetFromStyle(targetProperty))
291                                 return;
292
293                         var context = GetOrCreateContext(targetProperty);
294                         if (fromStyle)
295                                 context.Attributes |= BindableContextAttributes.IsSetFromStyle;
296                         else
297                                 context.Attributes &= ~BindableContextAttributes.IsSetFromStyle;
298
299                         if (context.Binding != null)
300                                 context.Binding.Unapply();
301
302                         BindingBase oldBinding = context.Binding;
303                         context.Binding = binding;
304
305                         targetProperty.BindingChanging?.Invoke(this, oldBinding, binding);
306
307                         binding.Apply(BindingContext, this, targetProperty);
308                 }
309
310                 bool CanBeSetFromStyle(BindableProperty property)
311                 {
312                         var context = GetContext(property);
313                         if (context == null)
314                                 return true;
315                         if ((context.Attributes & BindableContextAttributes.IsSetFromStyle) == BindableContextAttributes.IsSetFromStyle)
316                                 return true;
317                         if ((context.Attributes & BindableContextAttributes.IsDefaultValue) == BindableContextAttributes.IsDefaultValue)
318                                 return true;
319                         if ((context.Attributes & BindableContextAttributes.IsDefaultValueCreated) == BindableContextAttributes.IsDefaultValueCreated)
320                                 return true;
321                         return false;
322                 }
323
324                 internal void SetDynamicResource(BindableProperty property, string key)
325                 {
326                         SetDynamicResource(property, key, false);
327                 }
328
329                 internal void SetDynamicResource(BindableProperty property, string key, bool fromStyle)
330                 {
331                         if (property == null)
332                                 throw new ArgumentNullException(nameof(property));
333                         if (string.IsNullOrEmpty(key))
334                                 throw new ArgumentNullException(nameof(key));
335                         if (fromStyle && !CanBeSetFromStyle(property))
336                                 return;
337
338                         var context = GetOrCreateContext(property);
339
340                         context.Attributes |= BindableContextAttributes.IsDynamicResource;
341                         if (fromStyle)
342                                 context.Attributes |= BindableContextAttributes.IsSetFromStyle;
343                         else
344                                 context.Attributes &= ~BindableContextAttributes.IsSetFromStyle;
345
346                         OnSetDynamicResource(property, key);
347                 }
348
349                 internal void SetValue(BindableProperty property, object value, bool fromStyle)
350                 {
351                         SetValue(property, value, fromStyle, true);
352                 }
353
354                 internal void SetValueCore(BindablePropertyKey propertyKey, object value, SetValueFlags attributes = SetValueFlags.None)
355                 {
356                         SetValueCore(propertyKey.BindableProperty, value, attributes, SetValuePrivateFlags.None);
357                 }
358
359                 [EditorBrowsable(EditorBrowsableState.Never)]
360                 public void SetValueCore(BindableProperty property, object value, SetValueFlags attributes = SetValueFlags.None)
361                 {
362                         SetValueCore(property, value, attributes, SetValuePrivateFlags.Default);
363                 }
364
365                 internal void SetValueCore(BindableProperty property, object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes)
366                 {
367                         bool checkAccess = (privateAttributes & SetValuePrivateFlags.CheckAccess) != 0;
368                         bool manuallySet = (privateAttributes & SetValuePrivateFlags.ManuallySet) != 0;
369                         bool silent = (privateAttributes & SetValuePrivateFlags.Silent) != 0;
370                         bool fromStyle = (privateAttributes & SetValuePrivateFlags.FromStyle) != 0;
371                         bool converted = (privateAttributes & SetValuePrivateFlags.Converted) != 0;
372
373                         if (property == null)
374                                 throw new ArgumentNullException("property");
375                         if (checkAccess && property.IsReadOnly)
376                         {
377                                 Debug.WriteLine("Can not set the BindableProperty \"{0}\" because it is readonly.", property.PropertyName);
378                                 return;
379                         }
380
381                         if (!converted && !property.TryConvert(ref value))
382                         {
383                                 Console.WriteLine("SetValue", "Can not convert {0} to type '{1}'", value, property.ReturnType);
384                                 return;
385                         }
386
387                         if (property.ValidateValue != null && !property.ValidateValue(this, value))
388                                 throw new ArgumentException("Value was an invalid value for " + property.PropertyName, "value");
389
390                         if (property.CoerceValue != null)
391                                 value = property.CoerceValue(this, value);
392
393                         BindablePropertyContext context = GetOrCreateContext(property);
394                         if (manuallySet) {
395                                 context.Attributes |= BindableContextAttributes.IsManuallySet;
396                                 context.Attributes &= ~BindableContextAttributes.IsSetFromStyle;
397                         } else
398                                 context.Attributes &= ~BindableContextAttributes.IsManuallySet;
399
400                         if (fromStyle)
401                                 context.Attributes |= BindableContextAttributes.IsSetFromStyle;
402                         // else omitted on purpose
403
404                         bool currentlyApplying = _applying;
405
406                         if ((context.Attributes & BindableContextAttributes.IsBeingSet) != 0)
407                         {
408                                 Queue<SetValueArgs> delayQueue = context.DelayedSetters;
409                                 if (delayQueue == null)
410                                         context.DelayedSetters = delayQueue = new Queue<SetValueArgs>();
411
412                                 delayQueue.Enqueue(new SetValueArgs(property, context, value, currentlyApplying, attributes));
413                         }
414                         else
415                         {
416                                 context.Attributes |= BindableContextAttributes.IsBeingSet;
417                                 SetValueActual(property, context, value, currentlyApplying, attributes, silent);
418
419                                 Queue<SetValueArgs> delayQueue = context.DelayedSetters;
420                                 if (delayQueue != null)
421                                 {
422                                         while (delayQueue.Count > 0)
423                                         {
424                                                 SetValueArgs s = delayQueue.Dequeue();
425                                                 SetValueActual(s.Property, s.Context, s.Value, s.CurrentlyApplying, s.Attributes);
426                                         }
427
428                                         context.DelayedSetters = null;
429                                 }
430
431                                 context.Attributes &= ~BindableContextAttributes.IsBeingSet;
432                         }
433                 }
434
435                 internal void ApplyBindings(bool skipBindingContext, bool fromBindingContextChanged)
436                 {
437                         var prop = _properties.ToArray();
438                         for (int i = 0, propLength = prop.Length; i < propLength; i++) {
439                                 BindablePropertyContext context = prop [i];
440                                 BindingBase binding = context.Binding;
441                                 if (binding == null)
442                                         continue;
443
444                                 if (skipBindingContext && ReferenceEquals(context.Property, BindingContextProperty))
445                                         continue;
446
447                                 binding.Unapply(fromBindingContextChanged: fromBindingContextChanged);
448                                 binding.Apply(BindingContext, this, context.Property, fromBindingContextChanged: fromBindingContextChanged);
449                         }
450                 }
451
452                 static void BindingContextPropertyBindingChanging(BindableObject bindable, BindingBase oldBindingBase, BindingBase newBindingBase)
453                 {
454                         object context = bindable._inheritedContext;
455                         var oldBinding = oldBindingBase as Binding;
456                         var newBinding = newBindingBase as Binding;
457
458                         if (context == null && oldBinding != null)
459                                 context = oldBinding.Context;
460                         if (context != null && newBinding != null)
461                                 newBinding.Context = context;
462                 }
463
464                 static void BindingContextPropertyChanged(BindableObject bindable, object oldvalue, object newvalue)
465                 {
466                         bindable._inheritedContext = null;
467                         bindable.ApplyBindings(skipBindingContext: true, fromBindingContextChanged:true);
468                         bindable.OnBindingContextChanged();
469                 }
470
471                 void ClearValue(BindableProperty property, bool fromStyle, bool checkAccess)
472                 {
473                         if (property == null)
474                                 throw new ArgumentNullException(nameof(property));
475
476                         if (checkAccess && property.IsReadOnly)
477                                 throw new InvalidOperationException(string.Format("The BindableProperty \"{0}\" is readonly.", property.PropertyName));
478
479                         BindablePropertyContext bpcontext = GetContext(property);
480                         if (bpcontext == null)
481                                 return;
482
483                         if (fromStyle && !CanBeSetFromStyle(property))
484                                 return;
485
486                         object original = bpcontext.Value;
487
488                         object newValue = property.GetDefaultValue(this);
489
490                         bool same = Equals(original, newValue);
491                         if (!same)
492                         {
493                                 property.PropertyChanging?.Invoke(this, original, newValue);
494
495                                 OnPropertyChanging(property.PropertyName);
496                         }
497
498                         bpcontext.Attributes &= ~BindableContextAttributes.IsManuallySet;
499                         bpcontext.Value = newValue;
500                         if (property.DefaultValueCreator == null)
501                                 bpcontext.Attributes |= BindableContextAttributes.IsDefaultValue;
502                         else
503                                 bpcontext.Attributes |= BindableContextAttributes.IsDefaultValueCreated;
504
505                         if (!same)
506                         {
507                                 OnPropertyChanged(property.PropertyName);
508                                 property.PropertyChanged?.Invoke(this, original, newValue);
509                         }
510                 }
511
512                 [MethodImpl(MethodImplOptions.AggressiveInlining)]
513                 BindablePropertyContext CreateAndAddContext(BindableProperty property)
514                 {
515                         var context = new BindablePropertyContext { Property = property, Value = property.DefaultValueCreator != null ? property.DefaultValueCreator(this) : property.DefaultValue };
516
517                         if (property.DefaultValueCreator == null)
518                                 context.Attributes = BindableContextAttributes.IsDefaultValue;
519                         else
520                                 context.Attributes = BindableContextAttributes.IsDefaultValueCreated;
521
522                         _properties.Add(context);
523                         return context;
524                 }
525
526                 [MethodImpl(MethodImplOptions.AggressiveInlining)]
527                 BindablePropertyContext GetContext(BindableProperty property)
528                 {
529                         List<BindablePropertyContext> properties = _properties;
530
531                         for (var i = 0; i < properties.Count; i++)
532                         {
533                                 BindablePropertyContext context = properties[i];
534                                 if (ReferenceEquals(context.Property, property))
535                                         return context;
536                         }
537
538                         return null;
539                 }
540
541                 [MethodImpl(MethodImplOptions.AggressiveInlining)]
542                 BindablePropertyContext GetOrCreateContext(BindableProperty property)
543                 {
544                         BindablePropertyContext context = GetContext(property);
545                         if (context == null)
546                         {
547                                 context = CreateAndAddContext(property);
548                         }
549
550                         return context;
551                 }
552
553                 void RemoveBinding(BindableProperty property, BindablePropertyContext context)
554                 {
555                         context.Binding.Unapply();
556
557                         property.BindingChanging?.Invoke(this, context.Binding, null);
558
559                         context.Binding = null;
560                 }
561
562                 void SetValue(BindableProperty property, object value, bool fromStyle, bool checkAccess)
563                 {
564                         if (property == null)
565                                 throw new ArgumentNullException("property");
566
567                         if (checkAccess && property.IsReadOnly)
568                                 throw new InvalidOperationException(string.Format("The BindableProperty \"{0}\" is readonly.", property.PropertyName));
569
570                         if (fromStyle && !CanBeSetFromStyle(property))
571                                 return;
572
573                         SetValueCore(property, value, SetValueFlags.ClearOneWayBindings | SetValueFlags.ClearDynamicResource,
574                                 (fromStyle ? SetValuePrivateFlags.FromStyle : SetValuePrivateFlags.ManuallySet) | (checkAccess ? SetValuePrivateFlags.CheckAccess : 0));
575                 }
576
577                 void SetValueActual(BindableProperty property, BindablePropertyContext context, object value, bool currentlyApplying, SetValueFlags attributes, bool silent = false)
578                 {
579                         object original = context.Value;
580                         bool raiseOnEqual = (attributes & SetValueFlags.RaiseOnEqual) != 0;
581                         bool clearDynamicResources = (attributes & SetValueFlags.ClearDynamicResource) != 0;
582                         bool clearOneWayBindings = (attributes & SetValueFlags.ClearOneWayBindings) != 0;
583                         bool clearTwoWayBindings = (attributes & SetValueFlags.ClearTwoWayBindings) != 0;
584
585                         bool same = ReferenceEquals(context.Property, BindingContextProperty) ? ReferenceEquals(value, original) : Equals(value, original);
586                         if (!silent && (!same || raiseOnEqual))
587                         {
588                                 property.PropertyChanging?.Invoke(this, original, value);
589
590                                 OnPropertyChanging(property.PropertyName);
591                         }
592
593                         if (!same || raiseOnEqual)
594                         {
595                                 context.Value = value;
596                         }
597
598                         context.Attributes &= ~BindableContextAttributes.IsDefaultValue;
599                         context.Attributes &= ~BindableContextAttributes.IsDefaultValueCreated;
600
601                         if ((context.Attributes & BindableContextAttributes.IsDynamicResource) != 0 && clearDynamicResources)
602                                 RemoveDynamicResource(property);
603
604                         BindingBase binding = context.Binding;
605                         if (binding != null)
606                         {
607                                 if (clearOneWayBindings && binding.GetRealizedMode(property) == BindingMode.OneWay || clearTwoWayBindings && binding.GetRealizedMode(property) == BindingMode.TwoWay)
608                                 {
609                                         RemoveBinding(property, context);
610                                         binding = null;
611                                 }
612                         }
613
614                         if (!silent && (!same || raiseOnEqual))
615                         {
616                                 if (binding != null && !currentlyApplying)
617                                 {
618                                         _applying = true;
619                                         binding.Apply(true);
620                                         _applying = false;
621                                 }
622
623                                 OnPropertyChanged(property.PropertyName);
624
625                                 property.PropertyChanged?.Invoke(this, original, value);
626                         }
627                 }
628
629                 [Flags]
630                 enum BindableContextAttributes
631                 {
632                         IsManuallySet = 1 << 0,
633                         IsBeingSet = 1 << 1,
634                         IsDynamicResource = 1 << 2,
635                         IsSetFromStyle = 1 << 3,
636                         IsDefaultValue = 1 << 4,
637                         IsDefaultValueCreated = 1 << 5,
638                 }
639
640                 class BindablePropertyContext
641                 {
642                         public BindableContextAttributes Attributes;
643                         public BindingBase Binding;
644                         public Queue<SetValueArgs> DelayedSetters;
645                         public BindableProperty Property;
646                         public object Value;
647                 }
648
649                 [Flags]
650                 internal enum SetValuePrivateFlags
651                 {
652                         None = 0,
653                         CheckAccess = 1 << 0,
654                         Silent = 1 << 1,
655                         ManuallySet = 1 << 2,
656                         FromStyle = 1 << 3,
657                         Converted = 1 << 4,
658                         Default = CheckAccess
659                 }
660
661                 class SetValueArgs
662                 {
663                         public readonly SetValueFlags Attributes;
664                         public readonly BindablePropertyContext Context;
665                         public readonly bool CurrentlyApplying;
666                         public readonly BindableProperty Property;
667                         public readonly object Value;
668
669                         public SetValueArgs(BindableProperty property, BindablePropertyContext context, object value, bool currentlyApplying, SetValueFlags attributes)
670                         {
671                                 Property = property;
672                                 Context = context;
673                                 Value = value;
674                                 CurrentlyApplying = currentlyApplying;
675                                 Attributes = attributes;
676                         }
677                 }
678         }
679 }
680
681 namespace Tizen.NUI.Internals
682 {
683         [Flags]
684         [EditorBrowsable(EditorBrowsableState.Never)]
685         public enum SetValueFlags
686         {
687                 None = 0,
688                 ClearOneWayBindings = 1 << 0,
689                 ClearTwoWayBindings = 1 << 1,
690                 ClearDynamicResource = 1 << 2,
691                 RaiseOnEqual = 1 << 3
692         }
693 }