/// <summary> /// Is called by the managing DataNode when an update is broadcasted. /// </summary> /// <param name="updatedPath">Path that received a value update.</param> public void OnUpdate(Path updatedPath) { // Check if this does influence this binding if (BindingPath.IsSamePath(updatedPath) || BindingPath.IsSubpathOf(updatedPath)) { ForceUpdate(); } }
/// <summary> /// Triggered by managing DataNode if there is an value update. /// </summary> /// <param name="updatedPath">Path that has been updated.</param> public void OnUpdate(Path updatedPath) { // Check if this is for the list if (BindingPath.IsSamePath(updatedPath)) { // We might have to adjust the amount of children (list size expands / shrinks) IDataBindingOutputReadonly <IList> db = GetBinding() as IDataBindingOutputReadonly <IList>; IList boundList = db.GetValue(); int oldCount = updateReceivers.Count; int newCount = boundList.Count; int countDifference = oldCount - newCount; if (countDifference > 0) { // We have to remove some of the children for (int i = 0; i < countDifference; i++) { int removeIndex = oldCount - 1 - i; removeListEntryAt(removeIndex); } } if (countDifference < 0) { // We have to add some children for (int i = 0; i < -countDifference; i++) { int addIndex = oldCount + i; updateReceivers[addIndex] = makeListEntry(addIndex); } } ForceUpdate(); } else if (updatedPath.IsSubpathOf(BindingPath)) { Path subPath = updatedPath.GetSlice(BindingPath.PathElements.Count); PathElement indexPathElement = subPath.PathElements.First(); if (indexPathElement.Type != PathElement.PathElementType.Index) { throw new ArgumentException("Error at path '" + updatedPath.ToString() + "'. List has to be accessed by index."); } int index = indexPathElement.Index; updateReceivers[index].OnUpdate(subPath); } }