public ReListener(BidirectionalMapper iBidirectionalMapper) { _BidirectionalMapper = iBidirectionalMapper; var list = new JSCBridgeListenableVisitor((e) => _OldObject.Add(e), (e) => _OldCollections.Add(e), e => _OldCommands.Add(e)); _BidirectionalMapper.ApplyOnListenableReferencedObjects(list); }
private void Clean() { var newObject = new HashSet <INotifyPropertyChanged>(); var new_Collections = new HashSet <INotifyCollectionChanged>(); var new_Commands = new HashSet <JSCommand>(); var list = new JSCBridgeListenableVisitor((e) => newObject.Add(e), (e) => new_Collections.Add(e), e => new_Commands.Add(e)); _BidirectionalMapper.ApplyOnListenableReferencedObjects(list); _OldObject.Where(o => !newObject.Contains(o)).ForEach(o => o.PropertyChanged -= _BidirectionalMapper.Object_PropertyChanged); newObject.Where(o => !_OldObject.Contains(o)).ForEach(o => o.PropertyChanged += _BidirectionalMapper.Object_PropertyChanged); _OldCollections.Where(o => !new_Collections.Contains(o)).ForEach(o => o.CollectionChanged -= _BidirectionalMapper.CollectionChanged); new_Collections.Where(o => !_OldCollections.Contains(o)).ForEach(o => o.CollectionChanged += _BidirectionalMapper.CollectionChanged); _OldCommands.Where(o => !new_Commands.Contains(o)).ForEach(o => o.UnListenChanges()); new_Commands.Where(o => !_OldCommands.Contains(o)).ForEach(o => o.ListenChanges()); _BidirectionalMapper._ReListen = null; }