private static void GenerateValues(ICommandDispatcher dispatcher, MetadataDefinitionResource original, MetadataDefinitionResource updated) { if (original.ValuesMatch(updated)) return; dispatcher.Dispatch(new UpdateMetadataDefinitionValuesCommand(updated.Identity, updated.Values)); }
private static void GenerateUpdateRegexCommand(ICommandDispatcher dispatcher,MetadataDefinitionResource original, MetadataDefinitionResource updated) { if (original.RegexMatches(updated)) return; dispatcher.Dispatch(new UpdateMetadataDefinitionRegexCommand(updated.Identity,updated.Regex)); }
public MetaWeblogHandler( ICommandDispatcher commandDispatcher, ILogger logger) { _commandDispatcher = commandDispatcher; _logger = logger; }
private static void GenerateChangeDataTypeCommand(ICommandDispatcher dispatcher,MetadataDefinitionResource original, MetadataDefinitionResource updated) { if (original.DataTypeMatches(updated)) return; dispatcher.Dispatch(new ChangeMetadataDefinitionDataTypeCommand(updated.Identity, updated.DataType)); }
public FeatureOverridesModule(ICommandDispatcher commandDispatcher) { _commandDispatcher = commandDispatcher; Post["/api/featureoverrides"] = p => CreateFeatureOverride(); Put["/api/featureoverrides"] = p => UpdateFeatureOverride(); Delete["/api/featureoverrides"] = p => DeleteFeatureOverride(); }
public WorkModule(ICommandDispatcher dispatcher, ICommandDeserializer deserializer) { Post["/work"] = r => { object command; try { var reader = new StreamReader(Request.Body); string str = reader.ReadToEnd(); command = deserializer.Deserialize(str); } catch (InvalidCommandObjectException) { return new Response().WithStatusCode(HttpStatusCode.BadRequest); } try { dispatcher.Dispatch(command); return new Response().WithStatusCode(HttpStatusCode.OK); } catch (NoAvailableHandlerException) { return new Response().WithStatusCode(HttpStatusCode.NotImplemented); } }; }
private static void GenerateAssociationCommand(ICommandDispatcher dispatcher, MetadataDefinitionGroupResource original, MetadataDefinitionGroupResource updated) { if (original.DefinitionIdsMatch(updated)) return; dispatcher.Dispatch(new AssociateDefinitionsToMetadataDefinitionGroupCommand(original.Identity, updated.Definitions.Select(x=> x.Id).ToArray())); }
private static void GenerateReLabelCommand(ICommandDispatcher dispatcher, MetadataDefinitionGroupResource original, MetadataDefinitionGroupResource updated) { if (original.DiscriptionMatches(updated)) return; dispatcher.Dispatch(new ReLabelMetadataDefinitionGroupCommand(updated.Identity, new MetadataDefinitionGroupName(updated.Name), new MetadataDefinitionGroupDescription(updated.Description), updated.Tracking)); }
public void SetUp() { _commandDispatcher = Substitute.For<ICommandDispatcher>(); _boardRepository = Substitute.For<IBoardRepository>(); _controller = new BoardController(_commandDispatcher, _boardRepository); }
public BoardTaskController(ICommandDispatcher commandDispatcher, IQueryDispatcher queryDispatcher, IHyperMediaFactory hyperMediaFactory) { this.commandDispatcher = commandDispatcher; this.queryDispatcher = queryDispatcher; this.hyperMediaFactory = hyperMediaFactory; }
public WorkModule(ICommandDispatcher dispatcher, ICommandDeserializer deserializer) { Post["/work"] = r => { IUserSession userSession = this.UserSession(); object command; try { var reader = new StreamReader(Request.Body); string str = reader.ReadToEnd(); command = deserializer.Deserialize(str); } catch (InvalidCommandObjectException) { throw new BadRequestException("Invalid command object."); } try { dispatcher.Dispatch(userSession, command); return null; } catch (NoAvailableHandlerException) { throw new NotImplementedException("The command does not have a handler."); } }; }
public NewUserModule(IPasswordEncryptor passwordEncryptor, ICommandDispatcher commandDispatcher, IReadOnlyRepository readOnlyRepository) { Post["/user/facebook"] = r => { var newUserRequest = this.Bind<NewUserRequest>(); CheckForExistingFacebookUser(readOnlyRepository, newUserRequest); DispatchCommand(commandDispatcher, newUserRequest); return new Response().WithStatusCode(HttpStatusCode.OK); }; Post["/user"] = r => { var newUserRequest = this.Bind<NewUserRequest>(); CheckForExistingUser(readOnlyRepository, newUserRequest); commandDispatcher.Dispatch(this.VisitorSession(), new NewUserCommand { Email = newUserRequest.Email, EncryptedPassword = passwordEncryptor. Encrypt( newUserRequest. Password) }); return new Response().WithStatusCode(HttpStatusCode.OK); }; }
private static void GenerateChangeGroupCommand(ICommandDispatcher dispatcher, EntityResource original, EntityResource updated) { if (original.DefinitionGroup != null && Equals(original.DefinitionGroup.Id, updated.DefinitionGroup.Id)) return; dispatcher.Dispatch(new EntityChangedGroupCommand(updated.Identity, updated.DefinitionGroup.Id)); }
public void WhenIIssueACreateElectionCommand() { //setup the "bus" components m_commandDispatcher = new CommandDispatcher(); m_eventPublisher = new EventDispatcher(); //register the command handler var repository = MockRepository.GenerateStub<IRepository<Election>>(); m_commandDispatcher.Register(new MakeAnElectionCommandHandler(repository, null)); //register the event handler m_eventPublisher.RegisterHandler<ElectionMadeEvent>(@event => m_electionCreatedEvent = @event); //wire-up the domain event to the event publisher DomainEvents.Register<ElectionMadeEvent>(@event => m_eventPublisher.Publish(@event)); //create and send the command var command = new MakeAnElection { AdministratorCode = "AdmCode", CompanyCode = "CoCode", ParticipantId = "12345", ElectionAmount = 1000, ElectionReason = "election reason", }; m_commandDispatcher.Dispatch<MakeAnElection>(command); Assert.Pass(); }
public Form1(ClaimReader claimReader, ICommandDispatcher dispatcher, IWorkspace workspace) : this() { _claimReader = claimReader; _dispatcher = new ExceptionTrapDispatcher(dispatcher); this._workspace = workspace; }
private static void GenerateReLabelCommand(ICommandDispatcher dispatcher, EntityResource original, EntityResource updated) { if (original.DiscriptionMatches(updated)) return; dispatcher.Dispatch(new ReLabelEntityCommand(updated.Identity, new EntityName(updated.Name.Trim()))); }
public UserAccountModule(ICommandDispatcher commandDispatcher, IPasswordEncryptor passwordEncryptor) { Post["/register"] = _ => { var req = this.Bind<NewUserRequest>(); commandDispatcher.Dispatch(this.UserSession(), new CreateUser(req.Email, passwordEncryptor.Encrypt(req.Password), req.Name, req.PhoneNumber)); return null; }; Post["/password/requestReset"] = _ => { var req = this.Bind<ResetPasswordRequest>(); commandDispatcher.Dispatch(this.UserSession(), new CreatePasswordResetToken(req.Email) ); return null; }; Put["/password/reset/{token}"] = _ => { return null; }; }
public CommandQueueSubscriber(string connectionString, string queueName, ICommandDispatcher dispatcher, ILogger logger) { _dispatcher = dispatcher; _logger = logger; _client = QueueClient.CreateFromConnectionString(connectionString, queueName); _stopEvent = new ManualResetEvent(false); }
public SpeakersController( IQueryProcessor queryProcessor, ICommandDispatcher commandDispatcher) { _queryProcessor = queryProcessor; _commandDispatcher = commandDispatcher; }
private static void GenerateReLabelDescriptionCommand(ICommandDispatcher dispatcher, MetadataDefinitionResource original, MetadataDefinitionResource updated) { if (original.DescriptionMatches(updated)) return; dispatcher.Dispatch(new ReLabelMetadataDefinitionDescriptionCommand(updated.Identity, new MetadataDefinitionDescription(updated.Description.Trim()))); }
public DIContainer(AppSettings settings) { _settings = settings; _dispatcher = new CommandDispatcher( GetDefaultHandlers().ToArray(), GetPluginHandlers, EventDispatcher()); }
public OrderCreatorHub(ICommandDispatcher commandDispatcher, ICommandResponseWatcher commandResponseWatcher, IQueryDispatcher queryDispatcher, IConnectionManager connectionManager) { _commandDispatcher = commandDispatcher; _queryDispatcher = queryDispatcher; _connectionManager = connectionManager; commandResponseWatcher.ResponseReceived += CommandResponseReceived; }
public PaymentController(IQueryDispatcher queryDispatcher, ICommandDispatcher commandDispatcher, IAddressProvider addressProvider, ICreditCardService creditCardService, IPayPalService paypalService) { this._queryDispatcher = queryDispatcher; this._commandDispatcher = commandDispatcher; this._addressProvider = addressProvider; this._creditCardService = creditCardService; this._paypalService = paypalService; }
public DisasterModule(ICommandDispatcher commandDispatcher) { Post["/Disasters"] = Request => { commandDispatcher.Dispatch(this.UserSession(), this.Bind<CreateNewDisaster>()); return null; }; }
public SeverityModule(ICommandDispatcher commandDispatcher) { Post["/severity"] = r => { var voteRequest = this.Bind<VoteOnSeverityRequest>(); commandDispatcher.Dispatch(this.UserSession(), new VoteOnSeverity(voteRequest.DisasterId, voteRequest.Severity)); return null; }; }
public ApplicationsModule(ICommandDispatcher commandDispatcher, IQueryDispatcher queryDispatcher) { _commandDispatcher = commandDispatcher; _queryDispatcher = queryDispatcher; Get["/api/applications"] = p => GetApplications(); Post["/api/applications"] = p => PostApplication(); Put["/api/applications"] = p => PutApplication(); Delete["/api/applications"] = p => DeleteApplication(); }
public ResourcesModule(ICommandDispatcher commandDispatcher, IQueryDispatcher queryDispatcher) { _commandDispatcher = commandDispatcher; _queryDispatcher = queryDispatcher; Get["/api/resource"] = r => GetResource(); Get["/api/resources"] = r => GetResources(); Post["/api/resources"] = r => CreateResource(); Post["/api/resources/generate"] = r => GenerateResources(); Put["/api/resources"] = r => UpdateResource(); Delete["api/resources"] = r => DeleteResource(); }
public NewUserModule(IPasswordEncryptor passwordEncryptor, ICommandDispatcher commandDispatcher, IReadOnlyRepository readOnlyRepository) { Post["/user"] = r => { var newUserRequest = this.Bind<NewUserRequest>(); CheckForExistingUser(readOnlyRepository, newUserRequest); DispatchCommand(passwordEncryptor, commandDispatcher, newUserRequest); return new Response().WithStatusCode(HttpStatusCode.OK); }; }
public Engine( ICommandDispatcher commandDispatcher, IInputReader reader, IOutputWriter writer) { this.commandDispatcher = commandDispatcher; this.reader = reader; this.writer = writer; this.commandDispatcher.HardwRepository = HardwareRepositoty.Instance; this.isRunning = true; }
public FeaturesModule(ICommandDispatcher commandDispatcher, IQueryDispatcher queryDispatcher) { _commandDispatcher = commandDispatcher; _queryDispatcher = queryDispatcher; Post["/api/features"] = p => CreateFeature(); Put["/api/features"] = p => UpdateFeature(); Get["/api/features"] = p => GetFeatures(); Get["/api/feature"] = p => GetFeature(); Delete["/api/features"] = p => DeleteFeature(); }
protected ApiControllerBase(ICommandDispatcher commandDispatcher) { CommandDispatcher = commandDispatcher; }
public LocationController(ITwitterDataService twitterService, ICommandDispatcher commandDispatcher) { _twitterService = twitterService; _commandDispatcher = commandDispatcher; }
public LoginController(ILogger <LoginController> logger, ICommandDispatcher commandDispatcher) { _logger = logger; _commandDispatcher = commandDispatcher; }
public ApiControllerBase(ICommandDispatcher commandDispatcher) { CommandDispatcher = commandDispatcher; }
public UsersController(ICommandDispatcher commandDispatcher, IQueryDispatcher queryDispatcher, ICurrentUserService currentUserService) { _commandDispatcher = commandDispatcher; _queryDispatcher = queryDispatcher; _currentUserService = currentUserService; }
public UtilityController(ICommandDispatcher commands) { _commands = commands; }
public StudentsController(IQueryDispatcher queryDispatcher, ICommandDispatcher commandDispatcher) { _queryDispatcher = queryDispatcher; _commandDispatcher = commandDispatcher; }
public FriendshipsModuleFacade(ICommandDispatcher commandDispatcher, IQueryDispatcher queryDispatcher) { _commandDispatcher = commandDispatcher; _queryDispatcher = queryDispatcher; }
public ValuesController(ICommandDispatcher commandDispatcher) { _commandDispatcher = commandDispatcher; }
public UsersController(IUserService userService, ICommandDispatcher commandDispatcher) : base(commandDispatcher) { _userService = userService; }
public ProductsController(ICommandDispatcher commandDispatcher, IQueryDispatcher queryDispatcher) { this.commandDispatcher = commandDispatcher; this.queryDispatcher = queryDispatcher; }
public AccountController(ICommandDispatcher commandDispatcher) : base(commandDispatcher) { }
/// <summary> /// Assigns the specified domain event dispatcher. /// </summary> /// <param name="dispatcher">The command dispatcher.</param> /// <exception cref="System.ArgumentNullException"></exception> public static void Assign(ICommandDispatcher dispatcher) { _dispatcher = dispatcher; }
private static async Task RunDemo() { ICommandDispatcher dispatcher = _serviceProvider == null?Configure() : _serviceProvider.GetService <ICommandDispatcher>(); await dispatcher.DispatchAsync(new OutputToConsoleCommand { Message = "Hello Console" }); }
public CreateCardEndpoint(ICommandDispatcher commandDispatcher) { this.commandDispatcher = commandDispatcher ?? throw new ArgumentNullException(nameof(commandDispatcher)); }
public async Task <CommandResult <TResult> > DispatchAsync <TResult>(ICommand <TResult> command, CancellationToken cancellationToken) { await new SynchronizationContextRemover(); ICommandDispatchContext dispatchContext = _commandScopeManager.Enter(); try { CommandResult <TResult> dispatchResult = null; CommandResult wrappedDispatchResult = null; ICommandExecuter executer = null; ICommandDispatcher dispatcher = null; ICommand unwrappedCommand = command; if (command is NoResultCommandWrapper wrappedCommand) { unwrappedCommand = wrappedCommand.Command; } // we specifically audit BEFORE dispatch as this allows us to capture intent and a replay to // occur even if dispatch fails // (there is also an audit opportunity after execution completes and I'm considering putting one in // on dispatch success) await _auditor.AuditPreDispatch(unwrappedCommand, dispatchContext, cancellationToken); try { Stopwatch stopwatch = _collectMetrics ? Stopwatch.StartNew() : null; Func <ICommandDispatcher> dispatcherFunc = _commandRegistry.GetCommandDispatcherFactory(command); if (dispatcherFunc != null) { dispatcher = dispatcherFunc(); if (command != unwrappedCommand) { wrappedDispatchResult = await dispatcher.DispatchAsync(unwrappedCommand, cancellationToken); } else { dispatchResult = await dispatcher.DispatchAsync(command, cancellationToken); } executer = dispatcher.AssociatedExecuter; } await _auditor.AuditPostDispatch(unwrappedCommand, dispatchContext, stopwatch?.ElapsedMilliseconds ?? -1, cancellationToken); if ((dispatchResult != null && dispatchResult.DeferExecution) || (wrappedDispatchResult != null && wrappedDispatchResult.DeferExecution)) { return(new CommandResult <TResult>(default(TResult), true)); } } catch (Exception ex) { throw new CommandDispatchException(unwrappedCommand, dispatchContext.Copy(), dispatcher?.GetType() ?? GetType(), "Error occurred during command dispatch", ex); } if (executer == null) { executer = AssociatedExecuter; } return(new CommandResult <TResult>(await executer.ExecuteAsync(command, cancellationToken), false)); } finally { _commandScopeManager.Exit(); } }
public WishCompleteItemRequestHandler(ICommandDispatcher commandDispatcher) => _commandDispatcher = commandDispatcher;
public UpdateCurrencyController(ICommandDispatcher commandDispatcher, IQueryRunner queryRunner) { _commandDispatcher = commandDispatcher; _queryRunner = queryRunner; }
/// <summary> /// Initializes a new instance of the <see cref="ControllerBase"/> class. /// </summary> /// <param name="commandDispatcher">The command dispatcher.</param> /// <param name="queryDispatcher">The query dispatcher.</param> public ControllerBase(ICommandDispatcher commandDispatcher, IQueryDispatcher queryDispatcher) { CommandDispatcher = Guard.ArgumentNotNull(commandDispatcher, nameof(commandDispatcher)); QueryDispatcher = Guard.ArgumentNotNull(queryDispatcher, nameof(queryDispatcher)); }
public LoginController(ICommandDispatcher commandDispatcher, IMemoryCache memoryCache) : base(commandDispatcher) { _memoryCache = memoryCache; }
public AddWorkoutPlanJob(ICommandDispatcher commandDispatcher) { _commandDispatcher = commandDispatcher; }
public DriverRoutesController(ICommandDispatcher commandDispatcher) : base(commandDispatcher) { }
/// <summary> /// Initializes a new instance of the <see cref="CarsController"/> class. /// </summary> /// <param name="commandDispatcher">The command dispatcher.</param> /// <param name="queryDispatcher">The query dispatcher.</param> public CarsController(ICommandDispatcher commandDispatcher, IQueryDispatcher queryDispatcher) : base(commandDispatcher, queryDispatcher) { }
public CommandExecuter(IQueueClient queueClient, IConfig config, IWorkerRecordStoreService workerRecordStoreService, ICommandDispatcher dispatch, IDirectCommandExecuter directCommandExecuter) { _queueClient = queueClient; _config = config; _workerRecordStoreService = workerRecordStoreService; _dispatch = dispatch; _directCommandExecuter = directCommandExecuter; }
public LearnerMatchAndUpdate(ICommandDispatcher commandDispatcher, ILogger <LearnerMatchAndUpdate> logger) { _commandDispatcher = commandDispatcher; _logger = logger; }
public CategoryController(ICommandDispatcher commandDispatcher, IQueryDispatcher queryDispatcher) { this.commandDispatcher = commandDispatcher; this.queryDispatcher = queryDispatcher; }
public UsersController(IUserServices userServices, ICommandDispatcher commandDispatcher) : base(commandDispatcher) { _userServices = userServices; }
public FollowsController(ICommandDispatcher commandDispatcher) : base(commandDispatcher) { }
protected BaseController(ICommandDispatcher commandDispatcher) { CommandDispatcher = commandDispatcher; }
public Dispatcher(ICommandDispatcher commandDispatcher, IQueryDispatcher queryDispatcher) { _commandDispatcher = commandDispatcher; _queryDispatcher = queryDispatcher; }