private void OnBaseDocumentUnloaded(Document document) { ICollection keyCollection = dialogs.Keys; Type[] keys = new Type[keyCollection.Count]; keyCollection.CopyTo(keys, 0); for (int index = 0; index < keys.Length; index++) { Type type = keys[index]; BaseDialog dialog = dialogs[type] as BaseDialog; if ((dialog.Scope == DialogScope.Singleton) || (dialog.Scope == DialogScope.Document)) { dialog.Destroy(); } } }
private void OnBaseVideoUnloaded() { ICollection keyCollection = dialogs.Keys; Type[] keys = new Type[keyCollection.Count]; keyCollection.CopyTo(keys, 0); for (int index = 0; index < keys.Length; index++) { Type type = keys[index]; BaseDialog dialog = dialogs[type] as BaseDialog; if (dialog.Scope == DialogScope.Video) { dialog.Destroy(); } } }
/* Public methods */ public BaseDialog Get(Type dialogType, params object[] args) { BaseDialog dialog = dialogs[dialogType] as BaseDialog; if (dialog == null) { object newDialog = Activator.CreateInstance(dialogType, args); if (!(newDialog is BaseDialog)) { return(null); } dialog = newDialog as BaseDialog; if (dialog.Scope != DialogScope.Singleton) { dialogs[dialogType] = dialog; dialog.Destroyed += OnDialogDestroyed; } } return(dialog); }