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); }
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); } }
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}"); } }); }
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); }
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}"); } }); }
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); } }
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++ + "]"); } }
public static void BindEx <T>([CanBeNull] this T[] items, Lifetime lifetime, IRdDynamic parent, string name) where T : IRdBindable { Bind0(items, lifetime, parent, name); }
public SwitchingScheduler(IRdDynamic fallbackSchedulerSource) { myFallbackSchedulerSource = fallbackSchedulerSource; }
public virtual void Bind(Lifetime lf, IRdDynamic parent, string name) => Delegate.Bind(lf, parent, name);