public TwoWayBinding(BindPoint source, InvertibleArrow <T1, T2> arrow, BindPoint destination) : base(source, arrow, destination) { this.reverseArrow = arrow.Invert(); SubscribeToBindable(destination.Object); }
public static BindingHandle CreateBinding <A, B>(BindPoint source, Arrow <A, B> arrow, BindPoint destination) { /* * Creates a one-to-one binding from a source, an arrow and a destination. Infers * whether it should be bidirectional from the type of the supplied arrow. */ if (LinkWouldCauseConflict(source, destination)) { throw new BindingConflictException(); } Binding <A, B> result; if (arrow is InvertibleArrow <A, B> ) { result = new TwoWayBinding <A, B>(source, (InvertibleArrow <A, B>)arrow, destination); UpdateBindingGraphBothWays(source, destination); } else { result = new Binding <A, B>(source, arrow, destination); UpdateBindingGraph(source, destination); } BindingHandle handle = new BindingHandle(result); bindings.Add(handle, result); return(handle); }
public static BindingHandle CreateBinding <A, B>(Bindable source, string sourceProperty, Arrow <A, B> arrow, Bindable destination, string destinationProperty) { BindPoint sourcePoint = new BindPoint(source, sourceProperty); BindPoint destinationPoint = new BindPoint(destination, destinationProperty); return(CreateBinding(sourcePoint, arrow, destinationPoint)); }
//public Binding(Bindable source, string sourceVar, Bindable dest, string destVar) public Binding(BindPoint source, Arrow <T1, T2> arrow, BindPoint dest) { this.source = source; this.destination = dest; this.arrow = arrow; SubscribeToBindable(source.Object); }
public static bool LinkWouldCauseConflict(BindPoint a, BindPoint b) { BindingGraph tempGraph = bindGraph.Copy(); tempGraph.Add(a); tempGraph.Add(b); tempGraph.Bind(a, b); return(tempGraph.HasConflict()); }
private static dynamic GetValue(BindPoint point) { /* * Gets the value associated with a BindPoint * (This greatly simplifies the mess of calling Object.GetVariable<dynamic> everywhere) */ return(point.Object.GetVariable <dynamic>(point.Var)); }
public void TrySetVariable <T>(BindPoint bindPoint, T newValue) { try { bindPoint.Object.LockAndSetVariable(bindPoint.Var, newValue); } catch (VariableLockedException) { // Nothing to do here } }
private bool BindPointInList(BindPoint bindPoint, List <BindPoint> list) { bool isInList = false; foreach (BindPoint point in list) { isInList = isInList || (bindPoint.Object.Equals(point.Object) && bindPoint.Var == point.Var); } return(isInList); }
public override bool Equals(object obj) { if (obj is BindPoint) { BindPoint otherBindPoint = (BindPoint)obj; return(ReferenceEquals(this.Object, otherBindPoint.Object) && this.Var == otherBindPoint.Var); } else { return(false); } }
public static BindingHandle CreateBinding <A, B>(BindPoint source, Arrow <A, B> arrow, BindPoint destination) { // TODO: Check for cycles here Binding <A, B> result; if (arrow is InvertibleArrow <A, B> ) { result = new TwoWayBinding <A, B>(source, (InvertibleArrow <A, B>)arrow, destination); } else { result = new Binding <A, B>(source, arrow, destination); } return(new BindingHandle(result)); }
public static void UpdateBindingGraphBothWays(BindPoint a, BindPoint b) { UpdateBindingGraph(a, b); UpdateBindingGraph(b, a); }
public static void UpdateBindingGraph(BindPoint source, BindPoint destination) { bindGraph.AddMany(source, destination); bindGraph.Bind(source, destination); }