private void InstallActions()
        {
            if (commandPresentations != null)
            {
                return;
            }

            commandPresentations = new Dictionary <string, CommandPresentation>();

            foreach (var commandHandle in commandHandles)
            {
                CommandTraits traits = commandHandle.GetTraits();

                Commands2 commands = (Commands2)shell.DTE.Commands;

                Command command;
                try
                {
                    command = commands.Item(traits.CommandName, 0);
                }
                catch
                {
                    object[] contextGuids = null;
                    command = commands.AddNamedCommand2(shell.ShellAddIn,
                                                        traits.CommandName,
                                                        traits.Caption,
                                                        traits.Tooltip,
                                                        true, 59, ref contextGuids,
                                                        (int)ToVsCommandStatus(traits.Status),
                                                        (int)ToVsCommandStyle(traits.Style),
                                                        ToVsCommandControlType(traits.ControlType));
                }

                CommandBarButton[] controls = GenericCollectionUtils.ConvertAllToArray(traits.CommandBarPaths,
                                                                                       commandBarPath =>
                {
                    CommandBar commandBar             = GetCommandBar(commandBarPath);
                    CommandBarButton commandBarButton = GetOrCreateCommandBarButton(commandBar, command, commands);
                    return(commandBarButton);
                });

                CommandPresentation presentation = new CommandPresentation(commandHandle, command, controls);
                presentation.Icon    = traits.Icon;
                presentation.Caption = traits.Caption;
                presentation.Tooltip = traits.Tooltip;
                presentation.Status  = traits.Status;

                commandPresentations.Add(traits.CommandName, presentation);
            }
        }
        private void InstallActions()
        {
            if (commandPresentations != null)
                return;

            commandPresentations = new Dictionary<string, CommandPresentation>();

            foreach (var commandHandle in commandHandles)
            {
                CommandTraits traits = commandHandle.GetTraits();

                Commands2 commands = (Commands2) shell.DTE.Commands;

                Command command;
                try
                {
                    command = commands.Item(traits.CommandName, 0);
                }
                catch
                {
                    object[] contextGuids = null;
                    command = commands.AddNamedCommand2(shell.ShellAddIn,
                        traits.CommandName,
                        traits.Caption,
                        traits.Tooltip,
                        true, 59, ref contextGuids,
                        (int) ToVsCommandStatus(traits.Status),
                        (int) ToVsCommandStyle(traits.Style),
                        ToVsCommandControlType(traits.ControlType));
                }

                CommandBarButton[] controls = GenericCollectionUtils.ConvertAllToArray(traits.CommandBarPaths,
                    commandBarPath =>
                    {
                        CommandBar commandBar = GetCommandBar(commandBarPath);
                        CommandBarButton commandBarButton = GetOrCreateCommandBarButton(commandBar, command, commands);
                        return commandBarButton;
                    });

                CommandPresentation presentation = new CommandPresentation(commandHandle, command, controls);
                presentation.Icon = traits.Icon;
                presentation.Caption = traits.Caption;
                presentation.Tooltip = traits.Tooltip;
                presentation.Status = traits.Status;

                commandPresentations.Add(traits.CommandName, presentation);
            }
        }