Пример #1
0
        public void Bind(Lifetime lf, IRdDynamic parent, string name)
        {
            if (myParent != null)
            {
                Assertion.Fail($"Trying to bound already bound {this} to {parent.Location}");
            }
            //todo uncomment when fix InterningTest
            //Assertion.Require(RdId != RdId.Nil, "Must be identified first");

            lf.Bracket(() =>
            {
                myParent = parent;
                Location = parent.Location.Sub(name);
            },
                       () =>
            {
                Location = Location.Sub("<<unbound>>", "::");
                myParent = null;
                RdId     = RdId.Nil;
            }
                       );

            myDirectMap.Clear();
            myInverseMap.Clear();

            Proto.Wire.Advise(lf, this);
        }
Пример #2
0
 public static void BindEx <T>([CanBeNull] this T value, Lifetime lifetime, IRdDynamic parent, string name) where T : IRdBindable
 {
     if (value != null)
     {
         value.Bind(lifetime, parent, name);
     }
 }
Пример #3
0
        public override void Bind(Lifetime lf, IRdDynamic parent, string name)
        {
            base.Bind(lf, parent, name);
            Delegate.Changes.AdviseNotNull(lf, change =>
            {
                if (change.Origin == myLocalOrigin)
                {
                    return;
                }
                if (myActiveSession != null && myActiveSession.TryPushRemoteChange(change))
                {
                    return;
                }

                ReceiveChange(change);
            });

            Delegate.AssertedMasterText.Compose(lf, Delegate.AssertedSlaveText, Tuple.Create).Advise(lf, tuple =>
            {
                var m = tuple.Item1;
                var s = tuple.Item2;
                if (m.MasterVersion == s.MasterVersion &&
                    m.SlaveVersion == s.SlaveVersion &&
                    m.Text != s.Text)
                {
                    throw new Exception($"Master and Slave texts are different.\nMaster:\n{m.Text}\nSlave:\n{s.Text}");
                }
            });
        }
Пример #4
0
        public void Bind(Lifetime lf, IRdDynamic parent, string name)
        {
            if (Parent != null)
            {
                Assertion.Fail($"Trying to bound already bound {this} to {parent.Location}");
            }
            //todo uncomment when fix InterningTest
            //Assertion.Require(RdId != RdId.Nil, "Must be identified first");

            lf.Bracket(() =>
            {
                Parent         = parent;
                Location       = parent.Location.Sub(name);
                myBindLifetime = lf;
                IsBoundProperty.SetValue(true);
            },
                       () =>
            {
                IsBoundProperty.SetValue(false);
                myBindLifetime = Lifetime.Terminated;
                Location       = Location.Sub("<<unbound>>", "::");
                Parent         = null;
                RdId           = RdId.Nil;
            }
                       );

            Proto.Scheduler.AssertThread(this);

            using (Signal.PriorityAdviseCookie.Create())
                Init(lf);
        }
Пример #5
0
        public override void Bind(Lifetime lf, IRdDynamic parent, string name)
        {
            base.Bind(lf, parent, name);

            Delegate.Operation.AdviseNotNull(lf, op =>
            {
                if (op.Origin != LocalOrigin)
                {
                    ReceiveOperation(op);
                }
            });

            Delegate.Ack.Advise(lf, ack =>
            {
                if (ack.Origin != LocalOrigin)
                {
                    UpdateHistory(ack);
                }
            });

            Delegate.AssertedMasterText.Compose(lf, Delegate.AssertedSlaveText, (m, s) => new MasterSlave(m, s)).Advise(lf, ms =>
            {
                var m = ms.Master;
                var s = ms.Slave;
                if (m.MasterVersion == s.MasterVersion &&
                    m.SlaveVersion == s.SlaveVersion &&
                    m.Text != s.Text)
                {
                    throw new Exception($"Master and Slave texts are different.\nMaster:\n{m.Text}\nSlave:\n{s.Text}");
                }
            });
        }
Пример #6
0
 internal static void BindPolymorphic(this object value, Lifetime lifetime, IRdDynamic parent, string name)
 {
     if (value is IRdBindable rdBindable)
     {
         rdBindable.Bind(lifetime, parent, name);
     }
     else
     {
         //Don't remove 'else'. RdList is bindable and collection simultaneously.
         (value as IEnumerable)?.Bind0(lifetime, parent, name);
     }
 }
Пример #7
0
        private static void Bind0([CanBeNull] this IEnumerable items, Lifetime lifetime, IRdDynamic parent, string name)
        {
            if (items == null)
            {
                return;
            }

            var cnt = 0;

            foreach (var item in items)
            {
                (item as IRdBindable).BindEx(lifetime, parent, name + "[" + cnt++ + "]");
            }
        }
Пример #8
0
 public static void BindEx <T>([CanBeNull] this T[] items, Lifetime lifetime, IRdDynamic parent, string name) where T : IRdBindable
 {
     Bind0(items, lifetime, parent, name);
 }
Пример #9
0
 public SwitchingScheduler(IRdDynamic fallbackSchedulerSource)
 {
     myFallbackSchedulerSource = fallbackSchedulerSource;
 }
Пример #10
0
 public virtual void Bind(Lifetime lf, IRdDynamic parent, string name) => Delegate.Bind(lf, parent, name);