public void Copy(object original, CopyService copyService) { var org = (TrackableEvent)original; // create a copy without handlers _changeTracker = copyService.Copy(org._changeTracker); _handlers = new TrackableList <Action>(); _handlers.Initialize(_changeTracker); }
public void Copy(object original, CopyService copyService) { var org = (Publisher)original; _changeTracker = copyService.Copy(org._changeTracker); _eventsCache = org._eventsCache; _subscribersByEvent = new Dictionary <Type, TrackableList <object> >(); foreach (var subscriber in org._subscribersByEvent) { var subscribers = subscriber.Value .Where(x => IsUiComponent(x) == false) .Select(copyService.Copy); var trackableSubscribers = new TrackableList <object>(subscribers); trackableSubscribers.Initialize(_changeTracker); _subscribersByEvent.Add(subscriber.Key, trackableSubscribers); } }
public void Subscribe(object instance) { var events = _eventsCache.GetEvents(instance); if (events == null) { return; } foreach (var @event in events) { TrackableList <object> subscribers; if (!_subscribersByEvent.TryGetValue(@event, out subscribers)) { subscribers = new TrackableList <object>().Initialize(_changeTracker); _subscribersByEvent[@event] = subscribers; } subscribers.Add(instance); } }