public CommandController( ICommandHandler<CreateProductCommand> createProductCommandHandler, ICommandHandler<CreateProductVersionCommand> createProductVersionCommandHandler) { this.createProductCommandHandler = createProductCommandHandler; this.createProductVersionCommandHandler = createProductVersionCommandHandler; }
public Game() { characterQuery = new GetCharacterInfoQueryHandler(); choiceHandler = new UserChoiceHandler(); createCharacterHandler = new CreateCharacterHandler(); userValidator = new DatabaseUserValidator(); }
static void Main() { commandFactory = new CommandFactory(); log = new ConsoleWindowLogger(); commandHandler = new CommandHandler(commandFactory, log); Console.WindowHeight = 40; Console.WindowWidth = 120; PrintHelp(); while (true) { Thread.Sleep(300); Console.Write("> "); var line = Console.ReadLine(); if (string.IsNullOrWhiteSpace(line)) { continue; } var split = line.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); commandHandler.TryHandleRequest(split); Console.WriteLine(); } }
private static IEnumerable<Match> MatchCommands(CommandParameters parameters, int argCount, CommandHandlerDescriptor descriptor, ICommandHandler handler) { foreach (var commandDescriptor in descriptor.Commands) { foreach (var name in commandDescriptor.Names) { var names = name.Split(' '); // We check here number of arguments a command can recieve against // arguments provided for the command to identify the correct command // and avoid matching multiple commands. if(commandDescriptor.MethodInfo.GetParameters().Length == argCount - names.Count()) { names = parameters.Arguments.ToArray(); } if (parameters.Arguments.Take(argCount).SequenceEqual(names, StringComparer.OrdinalIgnoreCase)) { yield return new Match { Context = new CommandContext { Arguments = parameters.Arguments.Skip(name.Split(' ').Count()), Command = string.Join(" ", names), CommandDescriptor = commandDescriptor, Input = parameters.Input, Output = parameters.Output, Switches = parameters.Switches, }, CommandHandler = handler }; } } } }
public MainCommandHandlerChain( IConsole console, ICommandHandler[] commandHandlers) { _console = console; _commandHandlers = commandHandlers; }
public DocumentWindow(IServiceProvider serviceProvider, Microsoft.Matrix.Core.Documents.Document document) : base(serviceProvider) { if (document == null) { throw new ArgumentNullException("document"); } this._document = document; try { base.SuspendLayout(); this.InitializeUserInterface(); this._documentView = this.CreateDocumentView(); } finally { base.ResumeLayout(true); } this._documentView.DocumentChanged += new EventHandler(this.OnDocumentViewDocumentChanged); this._viewCommandHandler = this._documentView as ICommandHandler; this._viewToolboxClient = this._documentView as IToolboxClient; this._viewSelectionContainer = this._documentView as ISelectionContainer; IDesigner designer = ((IDesignerHost) serviceProvider.GetService(typeof(IDesignerHost))).GetDesigner(document); this._designerCommandHandler = designer as ICommandHandler; this._contextCommandHandler = this._document.ProjectItem.Project; this.UpdateCaption(); }
private static IEnumerable<Match> MatchCommands(CommandParameters parameters, int argCount, CommandHandlerDescriptor descriptor, ICommandHandler handler) { foreach (var commandDescriptor in descriptor.Commands) { foreach (var name in commandDescriptor.Names) { var names = name.Split(' '); if (parameters.Arguments.Take(argCount).SequenceEqual(names, StringComparer.OrdinalIgnoreCase)) { yield return new Match { Context = new CommandContext { Arguments = parameters.Arguments.Skip(names.Count()), Command = string.Join(" ", names), CommandDescriptor = commandDescriptor, Input = parameters.Input, Output = parameters.Output, Switches = parameters.Switches, }, CommandHandler = handler }; } } } }
public OrderApiService( ICommandHandler<MakeOrderCommand> commmHandler, IOrderRepository repository) { _commmHandler = commmHandler; _repository = repository; }
public AutoCompleteForm(TextView view, TextControl owner, TextBufferLocation location, ITextAutoCompletionList list) { this.InitializeComponent(); this._pickedItem = string.Empty; this._list = list; foreach (TextAutoCompletionItem item in list.Items) { this._itemList.Items.Add(item); } this._view = view; this._nextHandler = this._view.AddCommandHandler(this); this._owner = owner; if (location.ColumnIndex == location.Line.Length) { this._startLocation = location.Clone(); } else { using (TextBufferSpan span = this._view.GetWordSpan(location)) { this._startLocation = span.Start.Clone(); } } this._timer = new Timer(); this._timer.Interval = 500; this._timer.Tick += new EventHandler(this.OnTimerTick); }
public ShellViewModel( ITimerHandler timerHandler, IPlaybackHandler playbackHandler, ICommandHandler commandHandler ) { this.TimerHandler = timerHandler; this.playbackHandler = playbackHandler; this.TimerHandler.TimedEventCompleted += ( se, ea ) => { this.playbackHandler.PlayTimedEventComplete( se as TimedEvent ); }; commandHandler.CommandRecognized += ( se, ea ) => { this.playbackHandler.PlayCommandAccepted(); var command = se as Command; if ( command.Verb == "time" ) { this.TimerHandler.Start( command.Noun ); } else if ( command.Verb == "clear" ) { this.TimerHandler.Clear( command.Noun ); } }; }
public ServiceConsumer( ICommandHandler<AddDelegateCommand> addHandler, ICommandHandler<UpdateDelegateCommand> updateHandler) { this.addHandler = addHandler; this.updateHandler = updateHandler; }
public CommandExampleController( ICommandHandler<CreateOrderCommand> createOrderhandler, ICommandHandler<ShipOrderCommand> shipOrderhandler) { this.createOrderhandler = createOrderhandler; this.shipOrderhandler = shipOrderhandler; }
public void Register(ICommandHandler handler) { if (handler == null) throw new ArgumentNullException(nameof(handler)); var supportedCommandTypes = handler.GetType() .GetInterfaces() .Where(iface => iface.IsGenericType && iface.GetGenericTypeDefinition() == typeof(ICommandHandler<>)) .Select(iface => iface.GetGenericArguments()[0]) .ToList(); var registeredType = _handlers.Keys.FirstOrDefault(x => supportedCommandTypes.Contains(x)); if (registeredType != null) { var commands = String.Join(", ", supportedCommandTypes.Select(x => x.FullName)); var registeredHandler = _handlers[registeredType]; var message = $"The command(s) ('{commands}') handled by the received handler ('{handler}') already has a registered handler ('{registeredHandler}')."; Logging.Darjeel.TraceError(message); throw new ArgumentException(message); } foreach (var commandType in supportedCommandTypes) { _handlers.Add(commandType, handler); } }
public virtual void Invoke(ICommandHandler handler, ICommand command) { Ensure.That(handler, "handler").IsNotNull(); Ensure.That(command, "command").IsNotNull(); var container = ContainerFactory.Invoke(handler.ContainerType); handler.Handler.Invoke(container, new object[] { command }); }
public AccountController(ApplicationUserManager userManager, ApplicationSignInManager signInManager, ICommandHandler<RegisterUserCommand> registerUserCommandHandler) { UserManager = userManager; SignInManager = signInManager; _registerUserCommandHandler = registerUserCommandHandler; }
public ValidationService(IRequestResponsePairQueryService requestResponsePairQueryService, IUseCaseQueryService useCaseQueryService, ICommandHandler<CreateUseCaseValidation> commandHandler) { _requestResponsePairQueryService = requestResponsePairQueryService; _useCaseQueryService = useCaseQueryService; _commandHandler = commandHandler; }
public OrganizationController(ICommandHandler<CreateOrganization, Organization> createOrganization, IQueryHandler<GetOrganization, Organization> getOrganization, IQueryHandler<ListOrganizations, IEnumerable<Organization>> listOrganizations) { _createOrganization = createOrganization; _getOrganization = getOrganization; _listOrganizations = listOrganizations; }
public UserController(ICommandHandler<CreateBasicUser> createUserCommandHandler, ICommandHandler<AddFriendToUser> addFriendCommandHandler, ICommandHandler<DisableUser> disableUserCommandHandler, ICommandHandler<AddWishListItem> addWishListItemCommandHandler, ICommandHandler<EnableUser> enableUserCommandHandler) { _createUserCommandHandler = createUserCommandHandler; _addFriendCommandHandler = addFriendCommandHandler; _disableUserCommandHandler = disableUserCommandHandler; _addWishListItemCommandHandler = addWishListItemCommandHandler; _enableUserCommandHandler = enableUserCommandHandler; }
// ---------------------------------------------------------------------- public GenericCommand( ICommandHandler commandHandler, object context ) { if ( commandHandler == null ) { throw new ArgumentNullException( "commandHandler" ); } this.commandHandler = commandHandler; this.context = context; }
public CommandDispatcher( ICommandHandler[] handlers, Func<IEnumerable<ICommandHandler>> pluginHandlerFactory, IEventDispatcher eventDispatcher) { _handlers = handlers; _pluginHandlerFactory = pluginHandlerFactory; _eventDispatcher = eventDispatcher; }
/// <summary> /// Registers a handler to be used to process commands. /// </summary> public void RegisterCommandHandler(ICommandHandler commandHandler) { if (commandHandler == null) throw new ArgumentNullException("commandHandler"); if (registeredHandlers.Any(h => h.GetType() == commandHandler.GetType())) throw new InvalidOperationException("Handler type " + commandHandler.GetType() + " already registered."); registeredHandlers.Add(commandHandler); }
public LoginsController ( IRequestHandler<LoginRequest, string> loginHandler, ICommandHandler<LogoutRequest> logoutHandler ) { this.loginHandler = loginHandler; this.logoutHandler = logoutHandler; }
public void Setup() { command = new TestCommand(); commandHandler = Substitute.For<ICommandHandler<TestCommand>>(); commandHandlerResolver = Substitute.For<ICommandHandlerResolver>(); commandHandlerResolver.ResolveCommandHandler<ICommandHandler<TestCommand>>().Returns(commandHandler); sut = new CommandBus(commandHandlerResolver); }
private void RegisterCommandHandler(Type commandType, ICommandHandler commandHandler) { if (_commandHandlerDict.TryAdd(commandType, commandHandler)) return; if (_commandHandlerDict.ContainsKey(commandType)) { throw new DuplicatedCommandHandlerException(commandType, commandHandler.GetInnerCommandHandler().GetType()); } throw new ENodeException("Error occurred when registering {0} for {1} command.", commandHandler.GetType().Name, commandType.Name); }
public void Construct_MultipleCommandHandlersForSameCommand_ThrowArgumentException() { // The command bus doesn't currently support multiple command handlers for the same command, make sure that it fails. var commandHandlers = new ICommandHandler[] { new TestCommandHandler(), new TestCommandHandler() }; Assert.Throws<ArgumentException>(() => new CommandExecutor(commandHandlers)); }
public bool TryGetHandler(Type commandType, out ICommandHandler handler) { if (_handlers.TryGetValue(commandType, out handler)) { return true; } Logging.Darjeel.TraceInformation($"Handler not found for command '{commandType.FullName}'."); return false; }
private static List<ICommandHandler> SortCommandHandlers(ICommandHandler[] commandHandlers) { // Put command handlers defined in priority assemblies, last. This allows applications // to override built-in command handlers. var bootstrapper = IoC.Get<AppBootstrapper>(); return commandHandlers .OrderBy(h => bootstrapper.PriorityAssemblies.Contains(h.GetType().Assembly) ? 1 : 0) .ToList(); }
public void RegisterHandler(ICommandHandler<Command> commandHandler) { if (_handlers.ContainsKey(commandHandler.GetCommandType())) { throw new InvalidOperationException("Cannot register more than one similar handlers"); } else { _handlers.Add(commandHandler.GetCommandType(), commandHandler); } }
public ApprovalsController( IApprovalsViewRepository repository, ICurrentUserProvider userProvider, ICommandHandler<ApprovePromotionDraftCommand> approveHandler, ICommandHandler<RejectPromotionDraftCommand> rejectHandler) { _repository = repository; _userProvider = userProvider; _approveHandler = approveHandler; _rejectHandler = rejectHandler; }
/// <summary> /// Initializes a new instance of the <see cref="RollbackMessage"/> class. /// </summary> /// <param name="configuration">The configuration.</param> /// <param name="rollbackCommand">The rollback command.</param> /// <param name="headers">The headers.</param> public RollbackMessage(QueueConsumerConfiguration configuration, ICommandHandler<RollbackMessageCommand> rollbackCommand, SqlHeaders headers) { Guard.NotNull(() => configuration, configuration); Guard.NotNull(() => rollbackCommand, rollbackCommand); Guard.NotNull(() => headers, headers); _configuration = configuration; _rollbackCommand = rollbackCommand; _headers = headers; }
/// <summary> /// Creates a new <see cref="CliCommand"/> based on a name. /// </summary> /// <param name="commandName">The command name to look for; case-insensitive; can be <c>null</c>.</param> /// <param name="handler">A callback object used when the the user needs to be asked questions or informed about download and IO tasks.</param> /// <returns>The requested <see cref="CliCommand"/> or <see cref="DefaultCommand"/> if <paramref name="commandName"/> was <c>null</c>.</returns> /// <exception cref="OptionException"><paramref name="commandName"/> is an unknown command.</exception> /// <exception cref="IOException">There was a problem accessing a configuration file or one of the stores.</exception> /// <exception cref="UnauthorizedAccessException">Access to a configuration file or one of the stores was not permitted.</exception> /// <exception cref="InvalidDataException">A configuration file is damaged.</exception> public static CliCommand Create(string?commandName, ICommandHandler handler) => (commandName ?? "").ToLowerInvariant() switch { "" => new DefaultCommand(handler),
public UpdateSemesterCommandHander(ICommandHandler <UpdateEntityCommand, bool> updateEntityHandler) { this.updateEntityHandler = updateEntityHandler; }
/// <summary> /// Initializes a new instance of the <see cref="RollbackMessageCommandHandlerDecorator"/> class. /// </summary> /// <param name="handler">The handler.</param> /// <param name="tracer">The tracer.</param> public RollbackMessageCommandHandlerDecorator(ICommandHandler <RollbackMessageCommand <long> > handler, ITracer tracer) { _handler = handler; _tracer = tracer; }
/// <inheritdoc/> public ImportApps(ICommandHandler handler) : base(handler) { Options.Add("no-download", () => Resources.OptionNoDownload, _ => NoDownload = true); }
public CommandConsumer(ICommandHandler <T> commandHandler) { _commandHandler = commandHandler; }
public ResolutionScopeDecorator(ICommandHandler <TCommand> commandHandler, IDependencyContainer dependencyContainer) { _commandHandler = commandHandler; _dependencyContainer = dependencyContainer; }
public static Task WithCommandHandlerAsync <TCommand>(this IBusClient bus, ICommandHandler <TCommand> handler) where TCommand : ICommand => bus.SubscribeAsync <TCommand>(msg => handler.HandleAsync(msg), ctx => ctx.UseSubscribeConfiguration(cfg => // Multiple instances of same service should subscribe to same single queue. cfg.FromDeclaredQueue(q => q.WithName(GetQueueName <TCommand>()))));
public PaymentFailedEventHandler(ICommandHandler <CancelProductBooking> commandHandler, ILogger <PaymentFailedEventHandler> logger) : base(logger) { _commandHandler = commandHandler; }
public CreateSemesterCommandHandler(ICommandHandler <EntityCommand, int> createEntityHandler) { this.createEntityHandler = createEntityHandler; }
/// <inheritdoc/> public new void SetNext(ICommandHandler commandHandler) { this.nextHandler = commandHandler ?? throw new ArgumentNullException(nameof(commandHandler)); }
/// <inheritdoc/> public RepairApps([NotNull] ICommandHandler handler) : base(handler) { }
public MovieMetadataController(IQueryHandler <GetMovieMetadataQuery, List <DynamicMetadataDto> > getMovieMetadataQueryHandler, ICommandHandler <CreateMovieMetadataCommand, DynamicMetadataDto> createMovieMetadataCommandHandler, ICommandHandler <UpdateMovieMetadataCommand, DynamicMetadataDto> updateMovieMetadataCommandHandler, ICommandHandler <DeleteMovieMetadataCommand, bool> deleteMovieMetadataCommand) { _getMovieMetadataQueryHandler = getMovieMetadataQueryHandler; _createMovieMetadataCommandHandler = createMovieMetadataCommandHandler; _updateMovieMetadataCommandHandler = updateMovieMetadataCommandHandler; _deleteMovieMetadataCommand = deleteMovieMetadataCommand; }
public ValidatingCommandHandlerDecorator(ICommandHandler <TCommand> commandHandler, ILogger <ValidatingCommandHandlerDecorator <TCommand> > logger, ICommandValidator <TCommand> commandValidator) : base(commandHandler) { _commandValidator = commandValidator; _logger = logger; }
public static Task WithCommandHandlerAsync <TCommand>(this IBusClient bus, ICommandHandler <TCommand> handler) where TCommand : ICommand => bus.SubscribeAsync <TCommand>( msg => handler.HandleAsync(msg), ctx => ctx.UseConsumeConfiguration(cfg => cfg.FromQueue(GetQueueName <TCommand>())));
public CommandLoggingDecorator(ICommandHandler <TCommand> handler) { this.handler = handler; }
public AuditLoggingDecorator(ICommandHandler <TCommand> handler) { _handler = handler; }
public void SetSuccessor(ICommandHandler successor) { this.Successor = successor; }
public LogOutParameters(ICommandHandler handler, Action <LocalCommand> onSuccess = null, Action <LocalCommand> onFault = null) : base(handler, onSuccess, onFault) { }
public EndpointTransferredEventHandler(IQueryHandler queryHandler, ICommandHandler commandHandler, ILogger <EndpointTransferredEventHandler> logger) : base( queryHandler, commandHandler, logger) { }
/// <inheritdoc/> public AddFeed(ICommandHandler handler) : base(handler) { }
public EcSec1WriteFormattingDecorator(ICommandHandler <T> decoratedCommand, IEcKeyProvider ecKeyProvider) { this.decoratedCommand = decoratedCommand; this.ecKeyProvider = ecKeyProvider; }
public TransactionalCommandHandlerDecorator(ICommandHandler <T> handler) { Handler = handler; }
public CommandValidationDecorator(ICommandHandler <TCommand> commandHandler) { this.commandHandler = commandHandler ?? throw new ArgumentNullException(nameof(commandHandler)); }
public ClientCreateController(ICommandHandler <ClientCreateCommand> createClientCommandHandler) { _createClientCommandHandler = createClientCommandHandler; }
protected virtual void OnBeforeExecuteHandler <TCommand>(ICommandHandler <TCommand> handler, TCommand command) where TCommand : ICommand { // idle, override in ancestor if needed. }
public CreateValidFriendlyUrlCommandHandler( ICommandHandler <CreateProductCommand> decorated) { this.decorated = decorated; }
public CreateDisciplineCommandHandler(ICommandHandler <EntityCommand, int> createEntityHandler) { this.createEntityHandler = createEntityHandler; }
private bool TryGetControllerCommandHandler <TCommandArgs>(TCommandArgs args, out ICommandHandler <TCommandArgs> commandHandler) where TCommandArgs : CommandArgs { AssertIsForeground(); Controller controller; if (!TryGetController(args, out controller)) { commandHandler = null; return(false); } commandHandler = (ICommandHandler <TCommandArgs>)controller; return(true); }
public TransactionScopeCommandHandlerDecorator(ICommandHandler <TCommand> decoratee) { this.decoratee = decoratee; }
public CancelOrderConsumer(ICommandHandler <CancelOrder> handler) { _handler = handler; }