using System.Collections.Generic; using JetBrains.Lifetimes; using JetBrains.Rd.Base; using JetBrains.Rd.Util; namespace JetBrains.Rd.Reflection { public class RdReflectionBindableBase : RdBindableBase, IReflectionBindable { List> IReflectionBindable.BindableChildren => BindableChildren; private bool bindableChildrenFilled = false; void IReflectionBindable.EnsureBindableChildren() { if (bindableChildrenFilled) return; bindableChildrenFilled = true; BindableChildrenUtil.FillBindableFields(this); } /// /// Override this method to set-up data flow in your RdExt /// public virtual void OnActivated() { ((IReflectionBindable) this).EnsureBindableChildren(); } /// /// Reflection models can be bound on any thread /// protected override void AssertBindingThread() { } protected override void InitBindableFields(Lifetime lifetime) { ((IReflectionBindable) this).EnsureBindableChildren(); base.InitBindableFields(lifetime); } protected override void PreInitBindableFields(Lifetime lifetime) { ((IReflectionBindable) this).EnsureBindableChildren(); base.PreInitBindableFields(lifetime); } public override void Identify(IIdentities identities, RdId id) { ((IReflectionBindable) this).EnsureBindableChildren(); base.Identify(identities, id); } public override string ToString() { var prettyPrinter = new PrettyPrinter(); Print(prettyPrinter); return prettyPrinter.ToString(); } public override void Print(PrettyPrinter p) { BindableChildrenUtil.PrettyPrint(p, this); } } }