コード例 #1
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (_globalVerbs != null)
         {
             _globalVerbs.Clear();
             _globalVerbs = null;
         }
         if (_verbs != null)
         {
             _verbs.Clear();
             _verbs = null;
         }
         if (_commands != null)
         {
             _commands.Clear();
             _commands = null;
         }
         if (_serviceProvider != null)
         {
             ISelectionService selectionSvc = _serviceProvider.GetService(typeof(ISelectionService)) as ISelectionService;
             if (selectionSvc != null)
             {
                 selectionSvc.SelectionChanged -= OnSelectionChanged;
             }
             _serviceProvider = null;
         }
     }
 }
コード例 #2
0
        /// <summary>
        /// Release all used VS IDE menu resources.
        /// </summary>
        public void Dispose(bool deleteVsIdeElements)
        {
            verbs.Clear();
            commandItems.Clear();
            commandNames.Clear();
            commands.Clear();
            captions.Clear();
            namedCommands.Clear();

            if (deleteVsIdeElements)
            {
                foreach (CommandBarButton b in buttons)
                {
                    try
                    {
                        b.Delete(null);
                    }
                    catch (Exception ex)
                    {
                        Trace.Write(ex.Message);
                    }
                }

                foreach (CommandBarPopup p in popups)
                {
                    try
                    {
                        p.Delete(null);
                    }
                    catch (Exception ex)
                    {
                        Trace.Write(ex.Message);
                    }
                }

                foreach (CommandBar t in toolbars)
                {
                    try
                    {
                        t.Delete();
                    }
                    catch (Exception ex)
                    {
                        Trace.Write(ex.Message);
                    }
                }
            }

            buttons.Clear();
            popups.Clear();
            toolbars.Clear();
        }