public void OnDestroy() { if (OnFocus != null) { foreach (Delegate d in OnFocus.GetInvocationList()) { OnFocus -= (Action <IDialog>)d; } OnFocus = null; } if (OnBlur != null) { foreach (Delegate d in OnBlur.GetInvocationList()) { OnBlur -= (Action <IDialog>)d; } OnBlur = null; } if (OnShow != null) { foreach (Delegate d in OnShow.GetInvocationList()) { OnShow -= (Action <IDialog>)d; } OnShow = null; } if (OnHide != null) { foreach (Delegate d in OnHide.GetInvocationList()) { OnHide -= (Action <IDialog>)d; } OnHide = null; } if (OnClose != null) { foreach (Delegate d in OnClose.GetInvocationList()) { OnClose -= (Action <IDialog>)d; } OnClose = null; } if (OnCancel != null) { foreach (Delegate d in OnCancel.GetInvocationList()) { OnCancel -= (Action <IDialog>)d; } OnCancel = null; } }