コード例 #1
0
        private bool disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    // Dispose contained objects
                    UnregisterSolutionEventHandlers(CurrentSolution);
                    CurrentSolution?.Dispose();
                    foreach (var item in OpenFiles)
                    {
                        if (item is IDisposable)
                        {
                            (item as IDisposable).Dispose();
                        }
                    }

                    // Clear event handlers
                    SelectedFile          = null;
                    OpenFiles             = null;
                    this.FileOpened      -= ApplicationViewModel_FileOpened;
                    this.PropertyChanged -= ApplicationViewModel_PropertyChanged;
                }

                // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
                // TODO: set large fields to null.

                disposedValue = true;
            }
        }
コード例 #2
0
 public void DispatchSolutionUnload(SolutionEventArgs e)
 {
     CurrentSolution.Dispose();
     CurrentSolution = null;
     if (SolutionUnload != null)
     {
         SolutionUnload(this, e);
     }
 }