public void Handle(object sender, PropertyChangedEventArgs args) { bool hasDeadRef = false; var listeners = _listeners; for (int i = 0; i < listeners.Length; i++) { if (i >= _size) { break; } var pair = listeners[i]; if (pair.Key.IsEmpty) { hasDeadRef = true; continue; } if (ToolkitExtensions.MemberNameEqual(args.PropertyName, pair.Value, true)) { if (!pair.Key.EventListener.TryHandle(sender, args)) { hasDeadRef = true; } } } if (hasDeadRef) { lock (this) Cleanup(); } }
private bool MemberNameEqual(string memberName, IBindingSourceAccessor accessor) { if (string.IsNullOrEmpty(memberName)) { return(true); } var paths = ErrorPaths; bool hasPaths = paths != null && paths.Length != 0; if (hasPaths) { for (int i = 0; i < paths.Length; i++) { if (ToolkitExtensions.MemberNameEqual(memberName, paths[i], true)) { return(true); } } } else if (IsDirectSource) { return(true); } var singleAccessor = accessor as ISingleBindingSourceAccessor; string path; if (singleAccessor != null) { path = singleAccessor.Source.Path.Parts.LastOrDefault(); if (hasPaths && string.IsNullOrEmpty(path)) { return(false); } return(ToolkitExtensions.MemberNameEqual(memberName, path, true)); } for (int i = 0; i < accessor.Sources.Count; i++) { path = accessor.Sources[i].Path.Parts.LastOrDefault(); if (hasPaths && string.IsNullOrEmpty(path)) { continue; } if (ToolkitExtensions.MemberNameEqual(memberName, path, true)) { return(true); } } return(false); }
public void Handle(object sender, PropertyChangedEventArgs args) { bool hasDeadRef = false; var listeners = _listeners; for (int i = 0; i < listeners.Length; i++) { var pair = listeners[i]; if (ToolkitExtensions.MemberNameEqual(args.PropertyName, pair.Value, true)) { if (!pair.Key.EventListener.TryHandle(sender, args)) { hasDeadRef = true; } } } if (hasDeadRef) { lock (_propertyChanged) Update(WeakEventListenerWrapper.Empty, null); } }
protected static bool MemberNameEqual <T>(string memberName, Func <Expression <Func <T, object> > > getMember) { return(ToolkitExtensions.MemberNameEqual(memberName, getMember)); }