/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> public override void Dispose() { // Dispose the container last base.Dispose(); // Don't create the root ViewModel if it doesn't already exist... ScreenExtensions.TryDispose(this._rootViewModel); if (this.Container != null) { this.Container.Dispose(); } }
/// <summary> /// Close an item, and clear its parent if it's set to the current parent /// </summary> /// <typeparam name="T">Type of conductor</typeparam> /// <param name="parent">Parent</param> /// <param name="item">Item to close and clean up</param> /// <param name="dispose">True to dispose children as well as close them</param> public static void CloseAndCleanUp <T>(this IConductor <T> parent, T item, bool dispose) { ScreenExtensions.TryClose(item); var itemAsChild = item as IChild; if (itemAsChild != null && itemAsChild.Parent == parent) { itemAsChild.Parent = null; } if (dispose) { ScreenExtensions.TryDispose(item); } }