2 using System.Reflection;
4 namespace Tizen.NUI.Binding
6 internal abstract class Behavior : BindableObject, IAttachedObject
8 internal Behavior(Type associatedType)
10 if (associatedType == null)
11 throw new ArgumentNullException("associatedType");
12 AssociatedType = associatedType;
15 protected Type AssociatedType { get; }
17 void IAttachedObject.AttachTo(BindableObject bindable)
20 throw new ArgumentNullException("bindable");
21 if (!AssociatedType.IsInstanceOfType(bindable))
22 throw new InvalidOperationException("bindable not an instance of AssociatedType");
23 OnAttachedTo(bindable);
26 void IAttachedObject.DetachFrom(BindableObject bindable)
28 OnDetachingFrom(bindable);
31 protected virtual void OnAttachedTo(BindableObject bindable)
35 protected virtual void OnDetachingFrom(BindableObject bindable)
40 internal abstract class Behavior<T> : Behavior where T : BindableObject
42 protected Behavior() : base(typeof(T))
46 protected override void OnAttachedTo(BindableObject bindable)
48 base.OnAttachedTo(bindable);
49 OnAttachedTo((T)bindable);
52 protected virtual void OnAttachedTo(T bindable)
56 protected override void OnDetachingFrom(BindableObject bindable)
58 OnDetachingFrom((T)bindable);
59 base.OnDetachingFrom(bindable);
62 protected virtual void OnDetachingFrom(T bindable)