Beispiel #1
0
        /// <summary>
        /// 移除插件
        /// </summary>
        private void UninstallPlugin()
        {
            //移除命令
            foreach (var command in _dicCommand)
            {
                EnvDTE.Command cmd = _applicationObject.Commands.Item(command.Key);
                cmd.Delete();
            }

            //移除菜单
            foreach (var menu in _dicMenu)
            {
                MenuAttribute menuAttribute =
                    Attribute.GetCustomAttribute(menu.Value.GetType(), typeof(MenuAttribute)) as MenuAttribute;

                AdditionalBarAttribute[] additionalBarAttributes =
                    Attribute.GetCustomAttributes(menu.Value.GetType(), typeof(AdditionalBarAttribute)) as
                    AdditionalBarAttribute[];

                foreach (var s in additionalBarAttributes)
                {
                    CommandBar cmdBar = ((CommandBars)_applicationObject.CommandBars)[s.VsCommandBar];
                    cmdBar.Controls[menuAttribute.Caption].Delete();
                }
            }
            //插件卸载
            _initAlreadySetup = false;
        }
 private void DelectCommmand(params string[] commandNames)
 {
     foreach (string commandName in commandNames)
     {
         try
         {
             EnvDTE.Command cmd = _applicationObject.Commands.Item(Command.COMMAND_PREFIX + commandName, 1);
             cmd.Delete();
         }
         catch (Exception ex)
         {
         }
     }
 }