public void Dispose() { if (disposed) { return; } if (model.CommandModule != null) { model.CommandModule.ShowWindowCommandInvoked -= commandModule_ShowWindowCommandInvoked; } if (model.ChatCollectServiceModule != null) { model.ChatCollectServiceModule.ErrorOccurredInServiceCreation -= model_ErrorOccurredAtChatCollectServiceCreation; model.ChatCollectServiceModule.ErrorOccurredInChatPosting -= model_ErrorOccurredInChatPosting; model.ChatCollectServiceModule.ErrorOccurredInChatCollecting -= model_ErrorOccurredInChatCollecting; } if (model.Settings != null) { model.Settings.View.MainWindowPosition = new Model.Serialization.WindowPositionEntity() { X = WindowPosition.X, Y = WindowPosition.Y, Width = WindowPosition.Width, Height = WindowPosition.Height, }; model.Settings.View.ChatListViewColumns = ChatListColumnInfos?.Select( x => new ListViewColumnViewModel { Id = x.Id, Width = x.Width } ).ToArray(); model.Settings.View.MainWindowTab = this.SelectedTab.Value; } model.Dispose(); model.ApplicationClose -= CloseApplication; disposables.Dispose(); disposed = true; }