Example #1
0
        private void RegisterCommandResponseHandler(Type request, Type response, ICommandRegistrar registrar)
        {
            var methodInfo = typeof(ICommandRegistrar)
                             .GetMethod("RegisterCommandResponse", BindingFlags.Public | BindingFlags.Instance)
                             .MakeGenericMethod(request, response);

            methodInfo.Invoke(registrar, new object[0]);
        }
 /// <summary>
 /// Registers an example command group to be added to the context menu
 /// in the Intelligence Portal.
 /// This method is called by the Intelligence Portal application.
 /// </summary>
 /// <param name="registrar">The command registrar, which handles the
 /// registration of commands and command groups.</param>
 public void RegisterCommandGroupings(ICommandRegistrar registrar)
 {
     // Register the custom command group, requesting that it should be
     // displayed in the context menu after the refresh command and
     // before the default item commands. The Intelligence Portal
     // application determines the precise location of the group.
     registrar.RegisterCommandGrouping(
         commandGroupingId: ExampleCommandGroupingId,
         groupingHeading: CommandExtensibilityExampleStringResources.GroupHeading,
         groupingHeadingTooltip: CommandExtensibilityExampleStringResources.GroupHeadingTooltip,
         insertBeforeGroupings: new[] { DefaultItemCommands.ItemCommandsCommandGroupingType, DefaultItemCommands.SetCommandsCommandGroupingType },
         insertAfterGroupings: new[] { RefreshCommandProvider.RefreshCommandGroupingType });
 }
 /// <summary>
 /// Registers an example command group to be added to the context menu
 /// in the Intelligence Portal.
 /// This method is called by the Intelligence Portal application.
 /// </summary>
 /// <param name="registrar">The command registrar, which handles the
 /// registration of commands and command groups.</param>
 public void RegisterCommandGroupings(ICommandRegistrar registrar)
 {
     // Register the custom command group, requesting that it should be
     // displayed in the context menu after the refresh command and
     // before the default item commands. The Intelligence Portal
     // application determines the precise location of the group.
     registrar.RegisterCommandGrouping(
         commandGroupingId: ExampleCommandGroupingId, 
         groupingHeading: CommandExtensibilityExampleStringResources.GroupHeading, 
         groupingHeadingTooltip: CommandExtensibilityExampleStringResources.GroupHeadingTooltip, 
         insertBeforeGroupings: new[] { DefaultItemCommands.ItemCommandsCommandGroupingType, DefaultItemCommands.SetCommandsCommandGroupingType }, 
         insertAfterGroupings: new[] { RefreshCommandProvider.RefreshCommandGroupingType });
 }
Example #4
0
 public void Register(ICommandRegistrar registrar)
 {
     foreach (var service in _services.Select(x => x.ServiceType))
     {
         if (typeof (ICommandHandler).IsAssignableFrom(service))
         {
             var genericArguements = service.GetGenericArguments();
             if (genericArguements.Count() == 1)
                 RegisterCommandHandler(genericArguements[0], registrar);
             else
                 RegisterCommandResponseHandler(genericArguements[0], genericArguements[1], registrar);
         }
     }
 }
        /// <summary>
        /// Registers some additional commands to be added to the actions
        /// toolbar and the context menu in the Intelligence Portal.
        /// This method is called by the Intelligence Portal application.
        /// </summary>
        /// <param name="registrar">The command registrar, which handles the
        /// registration of commands and command groups.</param>
        public void RegisterCommands(ICommandRegistrar registrar)
        {
            // "displayItemDetailsCommand" displays item details, but only if
            // there is exactly one selected item, and that item came from the
            // example data source.
            var displayItemDetailsCommand = new SimpleCommand
                              {
                                  IsEnabled = CanDisplayItemDetails(),
                                  Action = RunDisplayItemDetailsTabIntent
                              };

            var displayItemDetailsNamedCommand = new NamedCommand(SubsettingExampleStringResources.DisplayItemDetailsCommandDisplayName, null, null, displayItemDetailsCommand, DisplayItemDetailsCommandId);

            // Register the command within the command group.
            registrar.RegisterCommands(new[] { displayItemDetailsNamedCommand }, ItemDetailsGroupingId, Enumerable.Empty<Guid>(), Enumerable.Empty<Guid>());
        }
        /// <summary>
        /// Registers some additional commands to be added to the actions
        /// toolbar and the context menu in the Intelligence Portal.
        /// This method is called by the Intelligence Portal application.
        /// </summary>
        /// <param name="registrar">The command registrar, which handles the
        /// registration of commands and command groups.</param>
        public void RegisterCommands(ICommandRegistrar registrar)
        {
            // "displayItemDetailsCommand" displays item details, but only if
            // there is exactly one selected item, and that item came from the
            // example data source.
            var displayItemDetailsCommand = new SimpleCommand
            {
                IsEnabled = CanDisplayItemDetails(),
                Action    = RunDisplayItemDetailsTabIntent
            };

            var displayItemDetailsNamedCommand = new NamedCommand(SubsettingExampleStringResources.DisplayItemDetailsCommandDisplayName, null, null, displayItemDetailsCommand, DisplayItemDetailsCommandId);

            // Register the command within the command group.
            registrar.RegisterCommands(new[] { displayItemDetailsNamedCommand }, ItemDetailsGroupingId, Enumerable.Empty <Guid>(), Enumerable.Empty <Guid>());
        }
Example #7
0
        public void Register(ICommandRegistrar registrar)
        {
            var registrations = _container.GetCurrentRegistrations();

            foreach (var registration in registrations)
            {
                if (typeof (ICommandHandler).IsAssignableFrom(registration.ServiceType))
                {
                    var genericArguements = registration.ServiceType.GetGenericArguments();
                    if (genericArguements.Count() == 1)
                        RegisterCommandHandler(genericArguements[0], registrar);
                    else
                        RegisterCommandResponseHandler(genericArguements[0], genericArguements[1], registrar);
                }
            }
        }
Example #8
0
 public void Register(ICommandRegistrar registrar)
 {
     foreach (var service in _services.Select(x => x.ServiceType))
     {
         if (typeof(ICommandHandler).IsAssignableFrom(service))
         {
             var genericArguments = service.GetGenericArguments();
             if (genericArguments.Count() == 1)
             {
                 RegisterCommandHandler(genericArguments[0], registrar);
             }
             else
             {
                 RegisterCommandResponseHandler(genericArguments[0], genericArguments[1], registrar);
             }
         }
     }
 }
Example #9
0
        public BusLifetime(
            RabbitMqServer server,
            ICommandDiscovery commandDiscovery,
            IEventDiscovery eventDiscovery,
            IEventRegistrar eventRegistrar,
            ICommandRegistrar commandRegistrar,
            ILogger <BusLifetime> logger)
        {
            _server           = server;
            _eventRegistrar   = eventRegistrar;
            _commandRegistrar = commandRegistrar;
            _logger           = logger;

            commandDiscovery.Register(_commandRegistrar);
            eventDiscovery.Register(_eventRegistrar);

            _server.DisablePriorityQueues      = true;
            _server.DisablePublishingResponses = true;
            _logger.Info("Starting RabbitMQ server");
            _server.Start();
        }
Example #10
0
        public void Register(ICommandRegistrar registrar)
        {
            var registrations = _container.GetCurrentRegistrations();
            var commandHandlers = registrations.Where(r => typeof (ICommandHandler).IsAssignableFrom(r.ServiceType));

            foreach (var commandHandler in commandHandlers)
            {
                var genericArguments = commandHandler.ServiceType.GetGenericArguments().ToList();
                switch (genericArguments.Count())
                {
                    case 1:
                        RegisterCommandHandler(genericArguments[0], registrar);
                        break;
                    case 2:
                        RegisterCommandResponseHandler(genericArguments[0], genericArguments[1], registrar);
                        break;
                    default:
                        throw new Exception("The service " + commandHandler.ServiceType + " must by of type ICommandHandler<T> or ICommandHandler<TRequest, TResponse>");
                }
            }
        }
Example #11
0
        public void Register(ICommandRegistrar registrar)
        {
            var registrations   = _container.GetCurrentRegistrations();
            var commandHandlers = registrations.Where(r => typeof(ICommandHandler).IsAssignableFrom(r.ServiceType));

            foreach (var commandHandler in commandHandlers)
            {
                var genericArguments = commandHandler.ServiceType.GetGenericArguments().ToList();
                switch (genericArguments.Count())
                {
                case 1:
                    RegisterCommandHandler(genericArguments[0], registrar);
                    break;

                case 2:
                    RegisterCommandResponseHandler(genericArguments[0], genericArguments[1], registrar);
                    break;

                default:
                    throw new Exception("The service " + commandHandler.ServiceType + " must by of type ICommandHandler<T> or ICommandHandler<TRequest, TResponse>");
                }
            }
        }
 /// <summary>
 /// Registers a command group to be added to the context menu in the
 /// Intelligence Portal.
 /// This method is called by the Intelligence Portal application.
 /// </summary>
 /// <param name="registrar">The command registrar, which handles the
 /// registration of commands and command groups.</param>
 public void RegisterCommandGroupings(ICommandRegistrar registrar)
 {
     // Add our own group of commands after the refresh, item, and set command groups.
     registrar.RegisterCommandGrouping(ItemDetailsGroupingId, SubsettingExampleStringResources.ItemDetailsCommandGroupHeading, null, Enumerable.Empty<Guid>(), new[] { RefreshCommandProvider.RefreshCommandGroupingType, DefaultItemCommands.ItemCommandsCommandGroupingType, DefaultItemCommands.SetCommandsCommandGroupingType });
 }
        /// <summary>
        /// Registers some additional commands to be added to the actions
        /// toolbar and the context menu in the Intelligence Portal.
        /// This method is called by the Intelligence Portal application.
        /// </summary>
        /// <param name="registrar">The command registrar, which handles the
        /// registration of commands and command groups.</param>
        public void RegisterCommands(ICommandRegistrar registrar)
        {
            // Register your custom commands here. You can specify where the
            // commands should appear in relation to other commands.

            // "command1" determines how many items are currently selected, and
            // displays a message that contains that information to the user.
            var command1 = new SimpleCommand
            {
                IsEnabled = true,
                Action    = () => mNotificationService.PresentAutoExpireSuccessfulActionNotificationToUser(
                    string.Format(CommandExtensibilityExampleStringResources.ExampleCommand1MessageFormat, mCommandsContext.SelectedModels.Count()))
            };

            var namedCommand1 = new NamedCommand(CommandExtensibilityExampleStringResources.ExampleCommand1DisplayName,
                                                 CommandExtensibilityExampleStringResources.ExampleCommand1Tooltip,
                                                 "/CommandExtensibilityExample;component/Assets/ExampleCommand1Icon.png",
                                                 command1,
                                                 ExampleCommand1Id);

            // "command2" determines whether the Intelligence Portal is
            // displaying information about a set, and reports that to the user.
            var command2 = new SimpleCommand
            {
                IsEnabled = true,
                Action    = () => mNotificationService.PresentAutoExpireSuccessfulActionNotificationToUser(
                    string.Format(CommandExtensibilityExampleStringResources.ExampleCommand2MessageFormat, mCommandsContext.SetContext != null ? CommandExtensibilityExampleStringResources.ExampleCommand2PositiveResponse : CommandExtensibilityExampleStringResources.ExampleCommand2NegativeResponse))
            };

            var namedCommand2 = new NamedCommand(CommandExtensibilityExampleStringResources.ExampleCommand2DisplayName,
                                                 CommandExtensibilityExampleStringResources.ExampleCommand2Tooltip,
                                                 "/CommandExtensibilityExample;component/Assets/ExampleCommand2Icon.png",
                                                 command2,
                                                 ExampleCommand2Id);

            // The commands added here appear in the given order, within the
            // given group. "command1" therefore appears before "command2".
            // There are no existing commands in the custom group, so there is
            // no need to specify "before" or "after" information.
            registrar.RegisterCommands(
                commands: new[] { namedCommand1, namedCommand2 },
                containingBlock: ExampleCommandGroupingId,
                insertBefore: Enumerable.Empty <Guid>(),
                insertAfter: Enumerable.Empty <Guid>());

            // "insertedcommand" just displays a message to indicate that the
            // user has selected it
            var insertedCommand = new SimpleCommand
            {
                IsEnabled = mCommandsContext.SelectedModels.Any(),
                Action    = () => mNotificationService.PresentAutoExpireSuccessfulActionNotificationToUser(
                    CommandExtensibilityExampleStringResources.ExampleInsertedCommandMessage)
            };

            var insertedNamedCommand = new NamedCommand(CommandExtensibilityExampleStringResources.ExampleInsertedCommandDisplayName,
                                                        CommandExtensibilityExampleStringResources.ExampleInsertedCommandTooltip,
                                                        "/CommandExtensibilityExample;component/Assets/InsertedCommandIcon.png",
                                                        insertedCommand,
                                                        ExampleInsertedCommandId);

            // Add "insertedcommand" into the list of standard commands,
            // rather than into its own group. This call requests that the
            // command is displayed after the delete command and before the
            // create link command.
            registrar.RegisterCommands(
                commands: new[] { insertedNamedCommand },
                containingBlock: DefaultItemCommands.ItemCommandsCommandGroupingType,
                insertBefore: new[] { DefaultItemCommands.DeleteCommandType },
                insertAfter: new[] { DefaultItemCommands.CreateLinkCommandType });
        }
Example #14
0
 private void RegisterCommandResponseHandler(Type request, Type response, ICommandRegistrar registrar)
 {
     var methodInfo = typeof(ICommandRegistrar).GetMethod("RegisterCommandResponse", BindingFlags.Public | BindingFlags.Instance).MakeGenericMethod(request, response);
     methodInfo.Invoke(registrar, new object[0]);
 }
        /// <summary>
        /// Registers some additional commands to be added to the actions
        /// toolbar and the context menu in the Intelligence Portal.
        /// This method is called by the Intelligence Portal application.
        /// </summary>
        /// <param name="registrar">The command registrar, which handles the
        /// registration of commands and command groups.</param>
        public void RegisterCommands(ICommandRegistrar registrar)
        {
            // Register your custom commands here. You can specify where the
            // commands should appear in relation to other commands.

            // "command1" determines how many items are currently selected, and
            // displays a message that contains that information to the user.
            var command1 = new SimpleCommand
                              {
                                  IsEnabled = true,
                                  Action = () => mNotificationService.PresentAutoExpireSuccessfulActionNotificationToUser(
                                               string.Format(CommandExtensibilityExampleStringResources.ExampleCommand1MessageFormat, mCommandsContext.SelectedModels.Count()))
                              };

            var namedCommand1 = new NamedCommand(CommandExtensibilityExampleStringResources.ExampleCommand1DisplayName, 
                                                 CommandExtensibilityExampleStringResources.ExampleCommand1Tooltip, 
                                                 "/CommandExtensibilityExample;component/Assets/ExampleCommand1Icon.png", 
                                                 command1, 
                                                 ExampleCommand1Id);

            // "command2" determines whether the Intelligence Portal is
            // displaying information about a set, and reports that to the user.
            var command2 = new SimpleCommand
            {
                IsEnabled = true,
                Action = () => mNotificationService.PresentAutoExpireSuccessfulActionNotificationToUser(
                             string.Format(CommandExtensibilityExampleStringResources.ExampleCommand2MessageFormat, mCommandsContext.SetContext != null ? CommandExtensibilityExampleStringResources.ExampleCommand2PositiveResponse : CommandExtensibilityExampleStringResources.ExampleCommand2NegativeResponse))
            };

            var namedCommand2 = new NamedCommand(CommandExtensibilityExampleStringResources.ExampleCommand2DisplayName, 
                                                 CommandExtensibilityExampleStringResources.ExampleCommand2Tooltip, 
                                                 "/CommandExtensibilityExample;component/Assets/ExampleCommand2Icon.png", 
                                                 command2, 
                                                 ExampleCommand2Id);

            // The commands added here appear in the given order, within the
            // given group. "command1" therefore appears before "command2".
            // There are no existing commands in the custom group, so there is
            // no need to specify "before" or "after" information.
            registrar.RegisterCommands(
                commands: new[] { namedCommand1, namedCommand2 }, 
                containingBlock: ExampleCommandGroupingId, 
                insertBefore: Enumerable.Empty<Guid>(), 
                insertAfter: Enumerable.Empty<Guid>());

            // "insertedcommand" just displays a message to indicate that the
            // user has selected it
            var insertedCommand = new SimpleCommand
            {
                IsEnabled = mCommandsContext.SelectedModels.Any(),
                Action = () => mNotificationService.PresentAutoExpireSuccessfulActionNotificationToUser(
                             CommandExtensibilityExampleStringResources.ExampleInsertedCommandMessage)
            };

            var insertedNamedCommand = new NamedCommand(CommandExtensibilityExampleStringResources.ExampleInsertedCommandDisplayName, 
                                                        CommandExtensibilityExampleStringResources.ExampleInsertedCommandTooltip, 
                                                        "/CommandExtensibilityExample;component/Assets/InsertedCommandIcon.png", 
                                                        insertedCommand, 
                                                        ExampleInsertedCommandId);

            // Add "insertedcommand" into the list of standard commands,
            // rather than into its own group. This call requests that the
            // command is displayed after the delete command and before the
            // create link command.
            registrar.RegisterCommands(
                commands: new[] { insertedNamedCommand },
                containingBlock: DefaultItemCommands.ItemCommandsCommandGroupingType,
                insertBefore: new[] { DefaultItemCommands.DeleteCommandType },
                insertAfter: new[] { DefaultItemCommands.CreateLinkCommandType });
        }
Example #16
0
 public CommandManager(DTE2 application, ICommandRegistrar commandRegistrar)
 {
     Application       = application;
     _commandRegistrar = commandRegistrar;
 }
 /// <summary>
 /// Registers a command group to be added to the context menu in the
 /// Intelligence Portal.
 /// This method is called by the Intelligence Portal application.
 /// </summary>
 /// <param name="registrar">The command registrar, which handles the
 /// registration of commands and command groups.</param>
 public void RegisterCommandGroupings(ICommandRegistrar registrar)
 {
     // Add our own group of commands after the refresh, item, and set command groups.
     registrar.RegisterCommandGrouping(ItemDetailsGroupingId, SubsettingExampleStringResources.ItemDetailsCommandGroupHeading, null, Enumerable.Empty <Guid>(), new[] { RefreshCommandProvider.RefreshCommandGroupingType, DefaultItemCommands.ItemCommandsCommandGroupingType, DefaultItemCommands.SetCommandsCommandGroupingType });
 }