/// <summary> /// Overrides the FirePropertyChanged method to fire the weakly held proxy events. /// </summary> protected override void FirePropertyChanged(string propName) { base.FirePropertyChanged(propName); bool shouldScavenge = false; for (int i = this.proxies.Count - 1; i >= 0; i--) { NavigationControllerProxy proxy = null; PropertyChangedEventHandler callback = null; WeakReference <NavigationControllerProxy> weakReference = this.proxies[i]; if (weakReference.TryGetTarget(out proxy) && this.callbackTable.TryGetValue(proxy, out callback)) { callback(this, new PropertyChangedEventArgs(propName)); } else { this.proxies.RemoveAt(i); shouldScavenge = true; } } // Remove all of the commands that have been GCed: if (shouldScavenge) { foreach (ObservableCommand command in this.allCommands) { command.CleanupUnheldProxies(); } } }
/// <summary> /// Registers a navigation proxy with the controller. This is a weak reference. /// </summary> /// <param name="proxy">The proxy to register</param> public void RegisterProxy(NavigationControllerProxy proxy, PropertyChangedEventHandler callback) { this.proxies.Add(new WeakReference<NavigationControllerProxy>(proxy)); this.callbackTable.Add(proxy, callback); }
/// <summary> /// Registers a navigation proxy with the controller. This is a weak reference. /// </summary> /// <param name="proxy">The proxy to register</param> public void RegisterProxy(NavigationControllerProxy proxy, PropertyChangedEventHandler callback) { this.proxies.Add(new WeakReference <NavigationControllerProxy>(proxy)); this.callbackTable.Add(proxy, callback); }