////////////////////////////////////////////////////////////////////////// public void iStart(ICommandValidator validator) { m_Validator = validator; m_Task = new Task(m_Activation); Core.Instance.m_TaskManager.AddTask(m_Task); }
protected TypedBaseHandler( IEventBus eventBus, ICommandValidator <TCommand> validator) : base(eventBus) { CommandValidator = validator; }
public void Send <TCommand>(TCommand command) where TCommand : ICommand <TAuthenticationToken> { ICommandValidator <TAuthenticationToken, TCommand> commandValidator = null; try { commandValidator = DependencyResolver.Resolve <ICommandValidator <TAuthenticationToken, TCommand> >(); } catch (Exception exception) { Logger.LogDebug("Locating an ICommandValidator failed.", string.Format("{0}\\Handle({1})", GetType().FullName, command.GetType().FullName), exception); } if (commandValidator != null && !commandValidator.IsCommandValid(command)) { Logger.LogInfo("The provided command is not valid.", string.Format("{0}\\Handle({1})", GetType().FullName, command.GetType().FullName)); return; } if (command.AuthenticationToken == null) { command.AuthenticationToken = AuthenticationTokenHelper.GetAuthenticationToken(); } command.CorrelationId = CorrelationIdHelper.GetCorrelationId(); ServiceBusPublisher.Send(new BrokeredMessage(MessageSerialiser.SerialiseCommand(command))); Logger.LogInfo(string.Format("A command was sent of type {0}.", command.GetType().FullName)); }
protected VoidBaseHandler( IEventBus eventBus, ICommandValidator <TCommand> commandValidator) : base(eventBus) { CommandValidator = commandValidator; }
public virtual bool PrepareAndValidateCommand <TCommand>(TCommand command, string framework) where TCommand : ICommand <TAuthenticationToken> { Type commandType = command.GetType(); if (command.Frameworks != null && command.Frameworks.Contains("Azure-EventHub")) { Logger.LogInfo("The provided command has already been processed in Azure.", string.Format("{0}\\PrepareAndValidateEvent({1})", GetType().FullName, commandType.FullName)); return(false); } ICommandValidator <TAuthenticationToken, TCommand> commandValidator = null; try { commandValidator = DependencyResolver.Resolve <ICommandValidator <TAuthenticationToken, TCommand> >(); } catch (Exception exception) { Logger.LogDebug("Locating an ICommandValidator failed.", string.Format("{0}\\PrepareAndValidateEvent({1})", GetType().FullName, commandType.FullName), exception); } if (commandValidator != null && !commandValidator.IsCommandValid(command)) { Logger.LogInfo("The provided command is not valid.", string.Format("{0}\\PrepareAndValidateEvent({1})", GetType().FullName, commandType.FullName)); return(false); } PrepareCommand(command, framework); return(true); }
/// <summary> /// Prepares and validates a <see cref="ICommand{TAuthenticationToken}"/> to be sent specifying the framework it is sent via. /// </summary> /// <typeparam name="TCommand">The <see cref="Type"/> of<see cref="ICommand{TAuthenticationToken}"/> being sent.</typeparam> /// <param name="command">The <see cref="ICommand{TAuthenticationToken}"/> to send.</param> /// <param name="framework">The framework the <paramref name="command"/> is being sent from.</param> public virtual bool PrepareAndValidateCommand <TCommand>(TCommand command, string framework) where TCommand : ICommand <TAuthenticationToken> { Type commandType = command.GetType(); if (command.Frameworks != null && command.Frameworks.Contains(framework)) { // if this is the only framework in the list, then it's fine to handle as it's just pre-stamped, if there is more than one framework, then exit. if (command.Frameworks.Count() != 1) { Logger.LogInfo("The provided command has already been processed in Azure.", string.Format("{0}\\PrepareAndValidateEvent({1})", GetType().FullName, commandType.FullName)); return(false); } } ICommandValidator <TAuthenticationToken, TCommand> commandValidator = null; try { commandValidator = DependencyResolver.Resolve <ICommandValidator <TAuthenticationToken, TCommand> >(); } catch (Exception exception) { Logger.LogDebug("Locating an ICommandValidator failed.", string.Format("{0}\\PrepareAndValidateEvent({1})", GetType().FullName, commandType.FullName), exception); } if (commandValidator != null && !commandValidator.IsCommandValid(command)) { Logger.LogInfo("The provided command is not valid.", string.Format("{0}\\PrepareAndValidateEvent({1})", GetType().FullName, commandType.FullName)); return(false); } PrepareCommand(command, framework); return(true); }
public AssignRoleToUserHandler( IEventBus eventBus, ICommandValidator <AssignRoleToUser> validator, IRoleAssignmentService roleAssignmentService) : base(eventBus, validator) { _roleAssignmentService = roleAssignmentService; }
/// <summary> /// Initializes a new instance of the <see cref="SaveUserAnswersHandler"/> class. /// </summary> /// <param name="eventBus"></param> /// <param name="commandValidator"></param> /// <param name="mediator"></param> public SaveUserAnswersHandler( IEventBus eventBus, ICommandValidator <SaveUserAnswers> commandValidator, IMediator mediator) : base(eventBus, commandValidator) { _mediator = mediator; }
public BeginPersonalityTestHandler( IEventBus eventBus, ICommandValidator <BeginPersonalityTest> validator, IUserQuestionAnswerRepository answerRepository) : base(eventBus, validator) { _answerRepository = answerRepository; }
public RegisterUserAnswerHandler( IEventBus eventBus, ICommandValidator <RegisterUserAnswer> commandValidator, IQuestionOptionRepository questionOptionRepository) : base(eventBus, commandValidator) { _questionOptionRepository = questionOptionRepository; }
public NewChatMessageCommandHandler( ICommandValidator <INewChatMessageCommand> commandValidator, IEventEmitter <INewChatMessageCommand> eventEmitter, IErrorEventEmitter <INewChatMessageCommand> errorEventEmitter, ILogger logger ) : base(commandValidator, eventEmitter, errorEventEmitter, logger) { }
public CommandProcessor( ICommandDispatcher commandDispatcher, ICommandValidator commandValidator, ITrackedMessageRepository trackedMessageRepository) { _commandDispatcher = commandDispatcher; _commandValidator = commandValidator; _trackedMessageRepository = trackedMessageRepository; }
public SubmitNecessaryDataHandler( IEventBus eventBus, ICommandValidator <SubmitNecessaryData> commandValidator, IUserPersonalDataRepository repository, IUserQuestionAnswerRepository answerRepository) : base(eventBus, commandValidator) { _repository = repository; _answerRepository = answerRepository; }
public Runner( ICommandValidator commandValidator, ITicketService ticketService, ILoggerFactory loggerFactory) { _commandValidator = commandValidator; _ticketService = ticketService; _logger = loggerFactory.CreateLogger <Runner>(); }
public void iStart(ICommandValidator validator) { m_CommandValidator = validator; if (m_CommandList.Count > 0) // continue or start from first { m_State = State.Running; m_CurrentCommand = m_CurrentCommand ?? m_CommandList.First; m_CommandInvoker.iInvoke(m_CurrentCommand.Value, this); } }
private static bool ValidateCommand(CommandHandlerRequest request) { Contract.Requires(request != null); Contract.Requires(request.Configuration != null); ICommandValidator validator = request.Configuration.Services.GetCommandValidator(); bool valid = validator.Validate(request); return(valid); }
public CommandCoordinator(IResolveHandler resolveHandler, IEventPublisher eventPublisher, ICommandValidator validation, IPermissionValidator permissionValidator, IMapper mapper, IMetrics metrics, ILogger logger) { _resolveHandler = resolveHandler.NotNull(); _eventPublisher = eventPublisher.NotNull(); _validation = validation.NotNull(); _permissionValidator = permissionValidator.NotNull(); _mapper = _mapper.NotNull(); _metrics = metrics.NotNull(); _logger = logger.NotNull(); }
public RegisterHandler( IEventBus eventBus, ICommandValidator <Register> commandValidator, IMapper mapper, IUserRepository userRepository) : base(eventBus, commandValidator) { _mapper = mapper; _userRepository = userRepository; }
public virtual void Send <TCommand>(TCommand command) where TCommand : ICommand <TAuthenticationToken> { Type commandType = command.GetType(); switch (command.Framework) { case FrameworkType.Akka: Logger.LogInfo(string.Format("A command arrived of the type '{0}' but was marked as coming from the '{1}' framework, so it was dropped.", commandType.FullName, command.Framework)); return; } ICommandValidator <TAuthenticationToken, TCommand> commandValidator = null; try { commandValidator = DependencyResolver.Resolve <ICommandValidator <TAuthenticationToken, TCommand> >(); } catch (Exception exception) { Logger.LogDebug("Locating an ICommandValidator failed.", string.Format("{0}\\Handle({1})", GetType().FullName, commandType.FullName), exception); } if (commandValidator != null && !commandValidator.IsCommandValid(command)) { Logger.LogInfo("The provided command is not valid.", string.Format("{0}\\Handle({1})", GetType().FullName, commandType.FullName)); return; } if (command.AuthenticationToken == null) { command.AuthenticationToken = AuthenticationTokenHelper.GetAuthenticationToken(); } command.CorrelationId = CorrelationIdHelper.GetCorrelationId(); bool isRequired; if (!ConfigurationManager.TryGetSetting(string.Format("{0}.IsRequired", commandType.FullName), out isRequired)) { isRequired = true; } RouteHandlerDelegate commandHandler = Routes.GetSingleHandler(command, isRequired); // This check doesn't require an isRequired check as there will be an exception raised above and handled below. if (commandHandler == null) { Logger.LogDebug(string.Format("The command handler for '{0}' is not required.", commandType.FullName)); return; } Action <IMessage> handler = commandHandler.Delegate; handler(command); }
public ServiceConsumer( ICommandHandler <AddDelegateCommand> addHandler, ICommandHandler <UpdateDelegateCommand> updateHandler, ICommandValidator <AddDelegateCommand> addValidator, ICommandValidator <UpdateDelegateCommand> updateValidator) { this.addHandler = addHandler; this.updateHandler = updateHandler; this.addValidator = addValidator; this.updateValidator = updateValidator; }
public CommandService( ICommandValidator commandValidator, IControlConnectionPool connectionPool, IResponseFactory responseFactory, ILogger <CommandService>?logger = null) { CommandValidator = commandValidator; ConnectionPool = connectionPool; ResponseFactory = responseFactory; Logger = logger ?? NullLogger <CommandService> .Instance; }
public ServiceConsumer( ICommandHandler<AddDelegateCommand> addHandler, ICommandHandler<UpdateDelegateCommand> updateHandler, ICommandValidator<AddDelegateCommand> addValidator, ICommandValidator<UpdateDelegateCommand> updateValidator) { this.addHandler = addHandler; this.updateHandler = updateHandler; this.addValidator = addValidator; this.updateValidator = updateValidator; }
public EntitiesService( IEntitiesRepository <ObjectIdentifier> entitiesRepository, ICommandValidator <CreateEntityCommand, Entity> createCommandValidator, ICommandValidator <UpdateEntityCommand, Entity> updateCommandValidator, IMapper mapper) { _entitiesRepository = entitiesRepository ?? throw new ArgumentNullException(nameof(entitiesRepository)); _createCommandValidator = createCommandValidator ?? throw new ArgumentNullException(nameof(createCommandValidator)); _updateCommandValidator = updateCommandValidator ?? throw new ArgumentNullException(nameof(updateCommandValidator)); _mapper = mapper ?? throw new ArgumentNullException(nameof(mapper)); }
private static void CreateHandlerValidatorTracer(ProcessorConfiguration configuration, ITraceWriter traceWriter) { Contract.Requires(configuration != null); ICommandValidator activator = GetService <ICommandValidator>(configuration.Services); if (activator != null && !(activator is CommandValidatorTracer)) { CommandValidatorTracer tracer = new CommandValidatorTracer(activator, traceWriter); configuration.Services.Replace(typeof(ICommandValidator), tracer); } }
protected CommandHandler(ICommandValidator <T> commandValidator, IEventEmitter <T, F> eventEmitter, IErrorEventEmitter <T, E, R> errorEventEmitter, ICommandHandler <T> handler, ILogger logger) { _validator = commandValidator; _eventEmitter = eventEmitter; _errorEventEmitter = errorEventEmitter; _handler = handler; _logger = logger; }
//protected bool m_UseParentInvoker; //protected bool m_UseParentValidator; ////////////////////////////////////////////////////////////////////////// public void iStart(ICommandValidator validator) { m_Validator = validator; m_CommandReceiver = validator as CommandReceiver; /*if (m_CommandReciver != null) * { // write this if needed * if (m_UseParentInvoker) * if (m_UseParentValidator) * }*/ Start(); }
public LoginHandler( IEventBus eventBus, ICommandValidator <Login> validator, IUserRepository userRepository, IdentityServerTools identityServerTools, IUserClaimsFactory userClaimsFactory) : base(eventBus, validator) { _userRepository = userRepository; _identityServerTools = identityServerTools; _userClaimsFactory = userClaimsFactory; }
////////////////////////////////////////////////////////////////////////// public void iStart(ICommandValidator validator) { if (m_Condition()) { m_ActionSelected = m_ActionTrue; } else { m_ActionSelected = m_ActionFalse; } m_ActionSelected.iStart(validator); }
public AddUserCommandHandler(IUnitOfWork unitOfWork, ICommandValidator <AddUser> commandValidator, IEmailSendService emailService, UserManager <User> userManager, GuidSignInManager signInManager, IConfiguration config, IHttpContextAccessor httpContextAccessor) { this.unitOfWork = unitOfWork; this.commandValidator = commandValidator; this.emailService = emailService; this.userManager = userManager; this.signInManager = signInManager; this.config = config; this.httpContextAccessor = httpContextAccessor; }
public IssuesController(ICreateIssueOperationService createIssueOperationService, IRenameIssueOperationService renameIssueIssueOperationService, IAddNoteToIssueOperationService addNoteIssueOperationService, IGetIssueOperationService getIssueOperationService, ICommandValidator <AddNoteToIssueCommand> addNoteToIssueCommandValidator, ICommandValidator <CreateIssueCommand> createIssueCommandValidator, ICommandValidator <RenameIssueCommand> renameIssueCommandValidator) { _createIssueOperationService = createIssueOperationService; _renameIssueOperationService = renameIssueIssueOperationService; _addNoteIssueOperationService = addNoteIssueOperationService; _getIssueOperationService = getIssueOperationService; _addNoteToIssueCommandValidator = addNoteToIssueCommandValidator; _createIssueCommandValidator = createIssueCommandValidator; _renameIssueCommandValidator = renameIssueCommandValidator; }
protected virtual bool PrepareAndValidateCommand <TCommand>(TCommand command, out RouteHandlerDelegate commandHandler) where TCommand : ICommand <TAuthenticationToken> { Type commandType = command.GetType(); if (command.Frameworks != null && command.Frameworks.Contains("Akka")) { // if this is the only framework in the list, then it's fine to handle as it's just pre-stamped, if there is more than one framework, then exit. if (command.Frameworks.Count() != 1) { Logger.LogInfo("The provided command has already been processed in Akka.", string.Format("{0}\\PrepareAndValidateEvent({1})", GetType().FullName, commandType.FullName)); commandHandler = null; return(false); } } ICommandValidator <TAuthenticationToken, TCommand> commandValidator = null; try { commandValidator = DependencyResolver.Resolve <ICommandValidator <TAuthenticationToken, TCommand> >(); } catch (Exception exception) { Logger.LogDebug("Locating an ICommandValidator failed.", string.Format("{0}\\Handle({1})", GetType().FullName, commandType.FullName), exception); } if (commandValidator != null && !commandValidator.IsCommandValid(command)) { Logger.LogInfo("The provided command is not valid.", string.Format("{0}\\Handle({1})", GetType().FullName, commandType.FullName)); commandHandler = null; return(false); } PrepareCommand(command); bool isRequired = BusHelper.IsEventRequired(commandType); commandHandler = Routes.GetSingleHandler(command, isRequired); // This check doesn't require an isRequired check as there will be an exception raised above and handled below. if (commandHandler == null) { Logger.LogDebug(string.Format("The command handler for '{0}' is not required.", commandType.FullName)); } return(true); }