Exemplo n.º 1
0
        public async Task <IActionResult> UpdateShiftById([FromBody] UpdateShiftRequestModel shiftRequestModel)
        {
            var result = await CommandRouter.RouteAsync <UpdateShiftCommand, IdResponse>(
                new UpdateShiftCommand(shiftRequestModel.ShiftId, shiftRequestModel.ShiftStart, shiftRequestModel.ShiftEnd, shiftRequestModel.EmployeeId));

            return(new ObjectResult(result));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> DeleteShiftById(Guid id)
        {
            var result =
                await CommandRouter.RouteAsync <DeleteShiftByIdCommand, IdResponse>(new DeleteShiftByIdCommand(id));

            return(new ObjectResult(result));
        }
Exemplo n.º 3
0
        public void SetUp()
        {
            _commandHandlerFactory = Substitute.For <ICommandHandlerFactory>();
            var testCommandHandler1 = Substitute.For <ICommandHandler <TestCommand> >();

            testCommandHandler1.CanHandle(Arg.Any <TestCommand>()).Returns(true);
            var testCommandHandler2 = Substitute.For <ICommandHandler <TestCommand> >();

            testCommandHandler2.CanHandle(Arg.Any <TestCommand>()).Returns(true);
            _test2CommandHandler = Substitute.For <ICommandHandler <Test2Command> >();
            _test2CommandHandler.CanHandle(Arg.Any <Test2Command>()).Returns(true);
            _test2Command = new Test2Command
            {
                Id = Guid.NewGuid()
            };
            _events = new[] { new Test2Event() };
            _test2CommandHandler.Handle(_test2Command).Returns(_events);
            var commandHandlerProvider = new CommandHandlerProvider(_commandHandlerFactory);

            commandHandlerProvider.RegisterCommandHandler(testCommandHandler1);
            commandHandlerProvider.RegisterCommandHandler(testCommandHandler2);
            commandHandlerProvider.RegisterCommandHandler(_test2CommandHandler);
            _eventHandler  = Substitute.For <IEventHandler>();
            _commandRouter = new CommandRouter(_eventHandler, commandHandlerProvider);
        }
Exemplo n.º 4
0
        public async Task Should_allow_dynamic_reconfiguration_down()
        {
            var router = new CommandRouter();
            int count  = 0;
            IPipe <InputContext> pipe = Pipe.New <InputContext>(cfg =>
            {
                cfg.UseRateLimit(100, TimeSpan.FromSeconds(1), router);
                cfg.UseExecute(cxt =>
                {
                    Interlocked.Increment(ref count);
                });
            });

            await router.SetRateLimit(10);

            var context = new InputContext("Hello");

            var timer = Stopwatch.StartNew();

            Task[] tasks = Enumerable.Range(0, 101)
                           .Select(index => Task.Run(async() => await pipe.Send(context)))
                           .ToArray();

            await Task.WhenAll(tasks);

            timer.Stop();

            Assert.That(timer.ElapsedMilliseconds, Is.GreaterThan(9500));
        }
Exemplo n.º 5
0
        public void SetUp()
        {
            var commandHandlerFactory = Substitute.For <ICommandHandlerFactory>();

            _commandHandlerProvider = new CommandHandlerProvider(commandHandlerFactory);
            _openTabCommandHandler  = new OpenTabCommandHandler();
            _commandHandlerProvider.RegisterCommandHandler(_openTabCommandHandler);
            CommandHandler = new TCommandHandler
            {
                Id = AggregateId
            };
            CommandHandler2 = new TCommandHandler
            {
                Id = _aggregateId2
            };

            if (!CanUsePreregisteredCommandHandlersToHandleCommand())
            {
                ConfigureCommandHandlerFactory(commandHandlerFactory);
            }

            _eventHandler  = Substitute.For <IEventHandler>();
            _commandRouter = new CommandRouter(_eventHandler, _commandHandlerProvider);
            _eventApplier  = new EventApplier(new TypeInspector());
        }
Exemplo n.º 6
0
        void OnPopupMenu(object o, EventArgs args)
        {
            object                 commandChain = this;
            CommandEntrySet        opset        = new CommandEntrySet();
            VersionControlItemList items        = GetSelectedItems();

            foreach (object ob in AddinManager.GetExtensionNodes("/MonoDevelop/VersionControl/StatusViewCommands"))
            {
                if (ob is TypeExtensionNode)
                {
                    TypeExtensionNode node = (TypeExtensionNode)ob;
                    opset.AddItem(ParseCommandId(node));
                    VersionControlCommandHandler handler = node.CreateInstance() as VersionControlCommandHandler;
                    if (handler == null)
                    {
                        LoggingService.LogError("Invalid type specified in extension point 'MonoDevelop/VersionControl/StatusViewCommands'. Subclass of 'VersionControlCommandHandler' expected.");
                        continue;
                    }
                    handler.Init(items);
                    CommandRouter rt = new CommandRouter(handler);
                    rt.Next      = commandChain;
                    commandChain = rt;
                }
                else
                {
                    opset.AddSeparator();
                }
            }
            IdeApp.CommandService.ShowContextMenu(opset, commandChain);
        }
        public async Task <IActionResult> UpdateTransporter(Guid id, [FromBody] TransporterRequestModel transporterRequestModel)
        {
            //var loggedIn = User.Claims.FirstOrDefault(c => c.Type == "sub").Value;


            var Transporter = await QueryRouter.QueryAsync <GetTransporterById, Transporter>(new GetTransporterById(id));

            if (Transporter != null)
            {
                if (String.IsNullOrEmpty(transporterRequestModel.Name))
                {
                    transporterRequestModel.Name = Transporter.Name;
                }
                if (String.IsNullOrEmpty(transporterRequestModel.Address))
                {
                    transporterRequestModel.Address = Transporter.Address;
                }
                if (transporterRequestModel.Telephone == 0)
                {
                    transporterRequestModel.Telephone = Transporter.Telephone;
                }
                if (String.IsNullOrEmpty(transporterRequestModel.Email))
                {
                    transporterRequestModel.Email = Transporter.Email;
                }
            }

            var result = await CommandRouter.RouteAsync <UpdateTransporterCommand, IdResponse>(
                new UpdateTransporterCommand(transporterRequestModel.Email, transporterRequestModel.Telephone,
                                             transporterRequestModel.Address, transporterRequestModel.Name, id)
                );

            return(!result.IsSuccessful ? Conflict(result) : new ObjectResult(result));
        }
Exemplo n.º 8
0
        public void CreateParkLotTest()
        {
            ICommands commands = new CommandRouter();

            commands.create_parking_lot("4");
            Assert.IsTrue(Program.ParkingLot != null && Program.ParkingLot.Cars.Length == 4);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Initialization of the package; this method is called right
        /// after the package is sited, so this is the place where you
        /// can put all the initialization code that rely on services
        /// provided by VisualStudio.
        /// </summary>
        ///
        /// <param name="cancellationToken">
        /// A cancellation token to monitor
        /// for initialization cancellation,
        /// which can occur when VS is
        /// shutting down.
        /// </param>
        ///
        /// <param name="progress">
        /// A provider for progress updates.
        /// </param>
        ///
        /// <returns>
        /// A task representing the async work of package initialization,
        /// or an already completed task if there is none. Do not return
        /// null from this method.
        /// </returns>
        protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            OleMenuCommandService oleMenuCommandService = await GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService;

            IVsSolution vsSolution = await GetServiceAsync(typeof(IVsSolution)) as IVsSolution;

            await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            IMessageHelper messageHelper = new MessageHelper(vsSolution, new ErrorListProvider(this));
            IProjectHelper projectHelper = new ProjectHelper();

            IPackageOption packageOption = (PackageOption)GetDialogPage(typeof(PackageOption));

            ((PackageOption)packageOption).Init(messageHelper);

            AbstractSwitch projectSwtich = new ProjectSwitch(true, ReferenceType.ProjectReference, packageOption, projectHelper, messageHelper);
            AbstractSwitch packageSwitch = new PackageSwitch(true, ReferenceType.PackageReference, packageOption, projectHelper, messageHelper);
            AbstractSwitch librarySwitch = new LibrarySwitch(true, ReferenceType.Reference, packageOption, projectHelper, messageHelper);

            ICommandRouter commandRouter = new CommandRouter(packageOption, projectSwtich, packageSwitch, librarySwitch);

            new CommandProject(commandRouter, messageHelper).Initialize(oleMenuCommandService, new Guid("c6018e68-fcab-41d2-a34a-42f7df92b162"), 0x0100);
            new CommandPackage(commandRouter, messageHelper).Initialize(oleMenuCommandService, new Guid("c6018e68-fcab-41d2-a34a-42f7df92b162"), 0x0200);
            new CommandLibrary(commandRouter, messageHelper).Initialize(oleMenuCommandService, new Guid("c6018e68-fcab-41d2-a34a-42f7df92b162"), 0x0300);
        }
Exemplo n.º 10
0
        public async Task <IActionResult> CreateNewBooking([FromBody] BookingRequestModel bookingRequestModel)
        {
            var          loggedIn   = User.Claims.FirstOrDefault(c => c.Type == "sub").Value;
            Guid         LoggedInID = new Guid(loggedIn);
            List <Order> orders     = new List <Order>();

            foreach (var order in bookingRequestModel.Orders)
            {
                orders.Add(new Order
                {
                    BookingId      = order.bookingId,
                    CustomerNumber = order.customerNumber,
                    WareNumber     = order.wareNumber,
                    OrderNumber    = order.orderNumber,
                    InOut          = order.InOut,
                    TotalPallets   = order.TotalPallets,
                    ExternalId     = order.ExternalId,
                    Comment        = order.Comment,
                    BottomPallets  = order.BottomPallets,
                    SupplierName   = order.SupplierName
                });
            }

            var result = await CommandRouter.RouteAsync <CreateBookingCommand, IdResponse>(
                new CreateBookingCommand(bookingRequestModel.totalPallets, bookingRequestModel.bookingTime,
                                         bookingRequestModel.transporterName, bookingRequestModel.port, bookingRequestModel.actualArrival,
                                         bookingRequestModel.startLoading, bookingRequestModel.endLoading, bookingRequestModel.email, orders, LoggedInID, bookingRequestModel.ExternalId, LoggedInID ));

            return(!result.IsSuccessful ? Conflict(result) : new ObjectResult(result));
        }
Exemplo n.º 11
0
        public void slotNumberForRegNo_NegTest()
        {
            Car[] cars = new Car[3]
            {
                new Car
                {
                    Color = "white",
                    RegistrationNumber = "KA-01-HH-1234",
                    SlotNumber         = 1
                },
                new Car
                {
                    Color = "red",
                    RegistrationNumber = "KA-01-HH-9876",
                    SlotNumber         = 2
                },
                new Car
                {
                    Color = "blue",
                    RegistrationNumber = "KA-01-KH-1762",
                    SlotNumber         = 3
                }
            };
            sampleLot = new Model.ParkingLot(4)
            {
                Cars = cars
            };
            ICommands commands = new CommandRouter();

            Program.ParkingLot = sampleLot;
            int slotNo = commands.slot_number_for_registration_number("KA-01-HH-0000");

            Assert.IsTrue(slotNo == -1);
        }
Exemplo n.º 12
0
        public static IRunner BuildRunner(Action<IConfigurationHelper> configurator)
        {
            var configPlan = new ConfigurationPlan();

            if (configurator != null)
            {
                configurator(configPlan);
            }

            configPlan.Validate();

            var routingInfo = GetRoutingInfo(configPlan);

            routingInfo.Validate();

            var router = new CommandRouter(routingInfo);

            var argsHelper = new ArgsHelper(configPlan.SwitchDelimiter);
            var argsHelpProvider = new ArgsParameterHelpProvider(argsHelper);
            var argsParameterBinder = new ArgsParameterBinder(argsHelper);

            var helpProvider = new HelpProvider(router, argsHelpProvider);
            var cmdProcessor = new CommandProcessor(router, configPlan.TypeInstantiationStrategy, argsParameterBinder);

            return new RunnerInternal(helpProvider, cmdProcessor);
        }
Exemplo n.º 13
0
        public void Should_be_called_when_send_faulted()
        {
            ICommandRouter router = new CommandRouter();

            router.ConnectPipe(Pipe.New <CommandContext <SetConcurrencyLimit> >(cfg =>
            {
                cfg.UseExecute(cxt =>
                {
                    throw new IntentionalTestException("Wow!");
                });
            }));

            var observer = new Observer <CommandContext <SetConcurrencyLimit> >();

            router.ConnectObserver(observer);

            var observer2 = new Observer();

            router.ConnectObserver(observer2);

            Assert.That(async() => await router.SetConcurrencyLimit(32), Throws.TypeOf <IntentionalTestException>());

            Assert.That(async() => await observer.SendFaulted, Throws.TypeOf <IntentionalTestException>());

            Assert.That(async() => await observer2.SendFaulted, Throws.TypeOf <IntentionalTestException>());
        }
Exemplo n.º 14
0
        public async Task <IActionResult> AssignSupplementTo(Guid userID, Guid suppId)
        {
            var result = await CommandRouter.RouteAsync <AssignSupplementToUserCommand, IdResponse>(
                new AssignSupplementToUserCommand(userID, suppId));

            return(new ObjectResult(result));
        }
Exemplo n.º 15
0
        public async Task <IActionResult> AssignToShift(Guid id, Guid shiftId)
        {
            var result = await CommandRouter.RouteAsync <AssignUserToShiftCommand, IdResponse>(
                new AssignUserToShiftCommand(id, shiftId));

            return(new ObjectResult(result));
        }
Exemplo n.º 16
0
        /// <summary>
        /// Create CommandHookContext from the WebHook of a comment.
        /// If the command is not on the list of <see cref="CommandRouter">CommandRouter</see>,
        /// or it is not a comment for pull request, return null
        /// </summary>
        /// <param name="req"></param>
        /// <returns>CommandHookContext object or null</returns>
        public async Task <CommandHookContext> ParseAsync(HttpRequest req)
        {
            string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
            var    comment     = JsonConvert.DeserializeObject <PRCommentCreated>(requestBody);

            var rawComment = comment?.comment?.body;
            var command    = rawComment?.Trim();

            if (CommandRouter.ContainsKey(command) && comment?.pull_request != null)
            {
                return(new CommandHookContext()
                {
                    Id = comment.comment?.id.ToString(),
                    Command = command,
                    PullRequestUri = new Uri(comment.pull_request.html_url),
                    PullRequestId = comment.pull_request.number.ToString(),
                    ReplyToId = comment.comment?.in_reply_to_id.ToString(),
                    RepositoryName = comment.repository.name,
                    RepositoryFullName = comment.repository.full_name
                });
            }
            else
            {
                return(null);
            }
        }
        public async Task <IActionResult> DeleteTransporter(Guid id)
        {
            var result =
                await CommandRouter.RouteAsync <DeleteTransporterCommand, IdResponse>(new DeleteTransporterCommand(id));

            return(!result.IsSuccessful ? Conflict(result) : new ObjectResult(result));
        }
Exemplo n.º 18
0
        public void StatusCheckTest()
        {
            Car[] cars = new Car[2]
            {
                new Car
                {
                    Color = "white",
                    RegistrationNumber = "KA-01-HH-1234",
                    SlotNumber         = 1
                },
                new Car
                {
                    Color = "red",
                    RegistrationNumber = "KA-01-HH-9876",
                    SlotNumber         = 2
                }
            };
            sampleLot = new Model.ParkingLot(4)
            {
                Cars = cars
            };
            ICommands commands = new CommandRouter();

            Program.ParkingLot = sampleLot;
            commands.status();

            Program.ParkingLot = null;
            Assert.ThrowsException <BaseException>(() => commands.status());
        }
Exemplo n.º 19
0
        static void Main(string[] args)
        {
            while (true)
            {
                Console.WriteLine(">>>");
                var command = Console.ReadLine();
                try
                {
                    RoutingStatus routingStatus = CommandRouter.RouteCommand(command);
                    switch (routingStatus)
                    {
                    case RoutingStatus.Quit:
                        Console.WriteLine("Exiting...");
                        return;

                    case RoutingStatus.Invalid:
                        Console.WriteLine(ErrorMessage.InvalidCommand);
                        Console.WriteLine(ConstantsKey.CommandHelp);
                        break;

                    case RoutingStatus.Success:
                        break;
                    }
                }
                catch (BaseException e)
                {
                    Console.WriteLine(e.Message);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Fatal Error: {0}", e.Message);
                }
            }
        }
Exemplo n.º 20
0
        public Task CreateIssueTransitionReplyComment(
            [ActivityTrigger] CreateIssueTransitionReplyCommentContext context)
        {
            var body = $"The issue marked as {CommandRouter.GetTransition(context.Command)}. For more [detail]({context.Issue.Url}).";

            return(_repository.CreatePullRequestReplyComment(int.Parse(context.PullRequestId), body,
                                                             int.Parse(context.InReplyTo)));
        }
        public async Task <IActionResult> CreateNewSupplier([FromBody] SupplierRequestModel supplierRequestModel)
        {
            var result = await CommandRouter.RouteAsync <CreateSupplierCommand, IdResponse>(
                new CreateSupplierCommand(supplierRequestModel.Email,
                                          supplierRequestModel.Telephone, supplierRequestModel.Name));

            return(!result.IsSuccessful ? Conflict(result) : new ObjectResult(result));
        }
Exemplo n.º 22
0
        public async Task <IActionResult> CreateNewOrder([FromBody] OrderRequestModel orderRequestModel)
        {
            var result = await CommandRouter.RouteAsync <CreateOrderCommand, IdResponse>(
                new CreateOrderCommand(orderRequestModel.bookingId, orderRequestModel.customerNumber,
                                       orderRequestModel.orderNumber, orderRequestModel.wareNumber, orderRequestModel.InOut));

            return(!result.IsSuccessful ? Conflict(result) : new ObjectResult(result));
        }
Exemplo n.º 23
0
        public async Task <IActionResult> AddUserToShift([FromBody] AddUserToShiftRequestModel addUserToShiftRequestModel)
        {
            var result = await CommandRouter.RouteAsync <AssignUserToShiftCommand, IdResponse>(
                new AssignUserToShiftCommand(addUserToShiftRequestModel.EmployeeOnShift,
                                             addUserToShiftRequestModel.id));

            return(new ObjectResult(result));
        }
Exemplo n.º 24
0
        /// <summary>
        /// Called when the Autoplay options have been updated and action specified
        /// </summary>
        /// <param name="selectedLibrary"></param>
        private void OptionsSelected(Autoplay newAutoplay, bool playNow)
        {
            // If any Autoplay options have changed then update them
            AutoplayModel.CurrentAutoplay.UpdateOptions(newAutoplay);

            // Pass the request on to the StartAutoPlaylistCommandHandler
            CommandRouter.HandleCommand(playNow ? Resource.Id.auto_play : Resource.Id.auto_queue, selectedObjects.SelectedObjects, commandCallback, commandButton);
        }
Exemplo n.º 25
0
 public ParkingController(DbContext dbContext, AuthenticationService authenticationService, CommandStoreService commandStoreService, ParkingQueryHandler queryHandler, CommandRouter commandRouter)
 {
     _dbContext             = dbContext;
     _authenticationService = authenticationService;
     _commandStoreService   = commandStoreService;
     _queryHandler          = queryHandler;
     _commandRouter         = commandRouter;
 }
Exemplo n.º 26
0
        public async Task <IActionResult> UpdateUserByIdObjectAsParam(Guid id, UpdateUserRequestModel userRequestModel)
        {
            //*****************Calls update controller on Identity API, so the db is synced***************************
            //var identityBaseurl = _identityConfig.Value.IdentityServerUrl + "/identity/users/" + id;
            var identityBaseurl = "https://localhost:5001/identity/users/" + id;
            var httpClient      = new HttpClient();

            httpClient.DefaultRequestHeaders
            .Accept
            .Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
            var jsonUpdateStatement = JsonConvert.SerializeObject(new UpdateIdentityUser
            {
                Email     = userRequestModel.Email,
                Password  = userRequestModel.Password,
                AuthLevel = userRequestModel.AccessLevel,
            }, Formatting.Indented);

            var httpContent    = new StringContent(jsonUpdateStatement, System.Text.Encoding.UTF8, "application/json");
            var identityResult = await httpClient.PutAsync(identityBaseurl, httpContent);


            if (!identityResult.IsSuccessStatusCode)
            {
                return(StatusCode(400, "Identity server could not be reached."));
            }

            //*********************Update API db (seperate from identity db)************************
            //Gets user from database to handle null and empty variables in the request model
            var user = await QueryRouter.QueryAsync <GetUserById, User>(new GetUserById(id));

            //if the variables are empty or null, (or 0 for access level), they wont be updated
            if (user != null)
            {
                if (string.IsNullOrWhiteSpace(userRequestModel.Name) && !string.IsNullOrWhiteSpace(user.Name))
                {
                    userRequestModel.Name = user.Name;
                }
                if (string.IsNullOrWhiteSpace(userRequestModel.Email) && !string.IsNullOrWhiteSpace(user.Email))
                {
                    userRequestModel.Email = user.Email;
                }
                if (userRequestModel.AccessLevel == 0)
                {
                    userRequestModel.AccessLevel = user.AccessLevel;
                }
                if (userRequestModel.Wage == 0)
                {
                    userRequestModel.Wage = user.BaseWage;
                }
            }


            var result = await CommandRouter.RouteAsync <UpdateUserCommand, IdResponse>(
                new UpdateUserCommand(userRequestModel.Name, userRequestModel.Email, userRequestModel.Password,
                                      userRequestModel.AccessLevel, userRequestModel.Wage, userRequestModel.EmploymentDate, id));

            return(new ObjectResult(result));
        }
Exemplo n.º 27
0
        public async Task <IActionResult> AddManyShifts([FromBody] AddManyShifts addUserToShiftRequestModel)
        {
            var result = await CommandRouter.RouteAsync <AddManyShiftsCommand, IdResponse>(
                new AddManyShiftsCommand(addUserToShiftRequestModel.listOfShifts));



            return(new ObjectResult(result));
        }
Exemplo n.º 28
0
        public async Task <IActionResult> UpdateShiftAndEmployee(
            [FromBody] UpdateShiftAndEmployeeRequestModel updateShiftAndEmployeeRequestModel)
        {
            var result = await CommandRouter.RouteAsync <CreateShiftWithEmployeeCommand, IdResponse>(
                new CreateShiftWithEmployeeCommand(updateShiftAndEmployeeRequestModel.ShiftStart,
                                                   updateShiftAndEmployeeRequestModel.ShiftEnd, updateShiftAndEmployeeRequestModel.EmployeeId));

            return(new ObjectResult(result));
        }
        public async Task <IActionResult> CreateNewTransporter([FromBody] TransporterRequestModel transporterRequestModel)
        {
            var result = await CommandRouter.RouteAsync <CreateTransporterCommand, IdResponse>(
                new CreateTransporterCommand(transporterRequestModel.Email,
                                             transporterRequestModel.Telephone, transporterRequestModel.Address,
                                             transporterRequestModel.Name));

            return(!result.IsSuccessful ? Conflict(result) : new ObjectResult(result));
        }
        public async Task <IActionResult> CreateNewSchedule([FromBody] ScheduleRequesteModel scheduleRequesteModel)
        {
            var result = await CommandRouter.RouteAsync <CreateScheduleCommand, IdResponse>(
                new CreateScheduleCommand(scheduleRequesteModel.ScheduleDay, scheduleRequesteModel.CreatedBy,
                                          scheduleRequesteModel.MischellaneousPallets, scheduleRequesteModel.shifts, scheduleRequesteModel.Intervals, scheduleRequesteModel.ScheduleId
                                          , scheduleRequesteModel.Name));

            return(!result.IsSuccessful ? Conflict(result) : new ObjectResult(result));
        }
Exemplo n.º 31
0
        static void Main(string[] args)
        {
            var commandRouter = new CommandRouter();

            commandRouter.Route(new ScheduleEvent
            {
                Id = Guid.NewGuid()
            }).Wait();
            Console.ReadKey();
        }
Exemplo n.º 32
0
        public void BeforeEach()
        {
            var type = typeof (Fodder);
            var exports = new List<Export>
                          {
                          	new Export(type, type.GetMethod("Bantha"), "fodder", "bantha")
                          };

            var routingInfo = new RoutingInfo(exports, "fodder");

            _router = new CommandRouter(routingInfo);
        }
Exemplo n.º 33
0
        internal EmacsCommandContext(
            EmacsCommandsManager manager,
            ITextStructureNavigatorSelectorService textStructureNavigatorSelectorService,
            IEditorOperations editorOperations,
            ITextView view,
            CommandRouter commandRouter)
        {
            this.Manager = manager;
            this.EditorOperations = editorOperations;
            this.TextView = view;
            this.CommandRouter = commandRouter;

            this.TextStructureNavigator = textStructureNavigatorSelectorService.GetTextStructureNavigator(view.TextBuffer);
            this.MarkSession = MarkSession.GetSession(view);
        }
Exemplo n.º 34
0
        public CommandRouter GetCommandRouter(ITextView view)
        {
            return view.Properties.GetOrCreateSingletonProperty<CommandRouter>(
                () => 
                    {
                        IOleCommandTarget nextCommandTarget = null;
                        IVsTextView textViewAdapter = EditorAdapterFactoryService.GetViewAdapter(view);
                        DTE dte = ServiceProvider.GetService<DTE>();

                        // create a new router and add it to the view's command chain
                        CommandRouter router = new CommandRouter(view, textViewAdapter as IOleCommandTarget, CompletionBroker, dte);

                        System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(textViewAdapter.AddCommandFilter(router, out nextCommandTarget));

                        router.Next = nextCommandTarget;

                        return router;
                    });
        }
Exemplo n.º 35
0
 public EmacsCommandsFilter(ITextView view, EmacsCommandsManager manager, CommandRouter router)
 {
     this.view = view;
     this.manager = manager;
     this.router = router;
 }
Exemplo n.º 36
0
		void DoPopupMenu (Gdk.EventButton evnt)
		{
			object commandChain = this;
			CommandEntrySet opset = new CommandEntrySet ();
			VersionControlItemList items = GetSelectedItems ();

			foreach (object ob in AddinManager.GetExtensionNodes ("/MonoDevelop/VersionControl/StatusViewCommands")) {
				if (ob is TypeExtensionNode) {
					TypeExtensionNode node = (TypeExtensionNode) ob;
					opset.AddItem (ParseCommandId (node));
					VersionControlCommandHandler handler = node.CreateInstance () as VersionControlCommandHandler;
					if (handler == null) {
						LoggingService.LogError ("Invalid type specified in extension point 'MonoDevelop/VersionControl/StatusViewCommands'. Subclass of 'VersionControlCommandHandler' expected.");
						continue;
					}
					handler.Init (items);
					CommandRouter rt = new CommandRouter (handler);
					rt.Next = commandChain;
					commandChain = rt;
				} else
					opset.AddSeparator ();
			}
			IdeApp.CommandService.ShowContextMenu (filelist, evnt, opset, commandChain);
 public static void Initialize(IRepository repository)
 {
     Repository = repository;
     CommandRouter = new CommandRouter(typeof(DomainLayer).Assembly);
 }