コード例 #1
0
        private static void GenerateValues(ICommandDispatcher dispatcher, MetadataDefinitionResource original, MetadataDefinitionResource updated)
        {
            if (original.ValuesMatch(updated))
                return;

            dispatcher.Dispatch(new UpdateMetadataDefinitionValuesCommand(updated.Identity, updated.Values));
        }
コード例 #2
0
        private static void GenerateUpdateRegexCommand(ICommandDispatcher dispatcher,MetadataDefinitionResource original, MetadataDefinitionResource updated)
        {
            if (original.RegexMatches(updated))
                return;

            dispatcher.Dispatch(new UpdateMetadataDefinitionRegexCommand(updated.Identity,updated.Regex));
        }
コード例 #3
0
 public MetaWeblogHandler(
     ICommandDispatcher commandDispatcher,
     ILogger logger)
 {
     _commandDispatcher = commandDispatcher;
     _logger = logger;
 }
コード例 #4
0
        private static void GenerateChangeDataTypeCommand(ICommandDispatcher dispatcher,MetadataDefinitionResource original, MetadataDefinitionResource updated)
        {
            if (original.DataTypeMatches(updated))
                return;

            dispatcher.Dispatch(new ChangeMetadataDefinitionDataTypeCommand(updated.Identity, updated.DataType));
        }
コード例 #5
0
 public FeatureOverridesModule(ICommandDispatcher commandDispatcher)
 {
     _commandDispatcher = commandDispatcher;
     Post["/api/featureoverrides"] = p => CreateFeatureOverride();
     Put["/api/featureoverrides"] = p => UpdateFeatureOverride();
     Delete["/api/featureoverrides"] = p => DeleteFeatureOverride();
 }
コード例 #6
0
ファイル: WorkModule.cs プロジェクト: realpasro09/FireTower
        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);
                                    }
                                };
        }
コード例 #7
0
        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()));
        }
コード例 #8
0
        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));
        }
コード例 #9
0
        public void SetUp()
        {
            _commandDispatcher = Substitute.For<ICommandDispatcher>();
            _boardRepository = Substitute.For<IBoardRepository>();

            _controller = new BoardController(_commandDispatcher, _boardRepository);
        }
コード例 #10
0
 public BoardTaskController(ICommandDispatcher commandDispatcher, IQueryDispatcher queryDispatcher,
     IHyperMediaFactory hyperMediaFactory)
 {
     this.commandDispatcher = commandDispatcher;
     this.queryDispatcher = queryDispatcher;
     this.hyperMediaFactory = hyperMediaFactory;
 }
コード例 #11
0
ファイル: WorkModule.cs プロジェクト: kmiloaguilar/FireTower
        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.");
                                    }
                                };
        }
コード例 #12
0
ファイル: NewUserModule.cs プロジェクト: rsiwady29/FireTower
        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);
                                };
        }
コード例 #13
0
        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));
        }
コード例 #14
0
        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();
        }
コード例 #15
0
ファイル: Form1.cs プロジェクト: gengle/ddd-vehicle-claims
 public Form1(ClaimReader claimReader, ICommandDispatcher dispatcher, IWorkspace workspace)
     : this()
 {
     _claimReader = claimReader;
     _dispatcher = new ExceptionTrapDispatcher(dispatcher);
     this._workspace = workspace;
 }
コード例 #16
0
        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())));
        }
コード例 #17
0
        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;
                };
        }
コード例 #18
0
 public CommandQueueSubscriber(string connectionString, string queueName, ICommandDispatcher dispatcher, ILogger logger)
 {
     _dispatcher = dispatcher;
     _logger = logger;
     _client = QueueClient.CreateFromConnectionString(connectionString, queueName);
     _stopEvent = new ManualResetEvent(false);
 }
コード例 #19
0
 public SpeakersController(
     IQueryProcessor queryProcessor,
     ICommandDispatcher commandDispatcher)
 {
     _queryProcessor = queryProcessor;
     _commandDispatcher = commandDispatcher;
 }
コード例 #20
0
        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())));
        }
コード例 #21
0
ファイル: DIContainer.cs プロジェクト: JamesTryand/OpenIDE
 public DIContainer(AppSettings settings)
 {
     _settings = settings;
     _dispatcher = new CommandDispatcher(
         GetDefaultHandlers().ToArray(),
         GetPluginHandlers,
         EventDispatcher());
 }
コード例 #22
0
        public OrderCreatorHub(ICommandDispatcher commandDispatcher, ICommandResponseWatcher commandResponseWatcher, IQueryDispatcher queryDispatcher, IConnectionManager connectionManager)
        {
            _commandDispatcher = commandDispatcher;
            _queryDispatcher = queryDispatcher;
            _connectionManager = connectionManager;

            commandResponseWatcher.ResponseReceived += CommandResponseReceived;
        }
コード例 #23
0
 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;
 }
コード例 #24
0
 public DisasterModule(ICommandDispatcher commandDispatcher)
 {
     Post["/Disasters"] =
         Request =>
             {
                 commandDispatcher.Dispatch(this.UserSession(), this.Bind<CreateNewDisaster>());
                 return null;
             };
 }
コード例 #25
0
 public SeverityModule(ICommandDispatcher commandDispatcher)
 {
     Post["/severity"] = r =>
         {
             var voteRequest = this.Bind<VoteOnSeverityRequest>();
             commandDispatcher.Dispatch(this.UserSession(), new VoteOnSeverity(voteRequest.DisasterId, voteRequest.Severity));
             return null;
         };
 }
コード例 #26
0
        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();
        }
コード例 #27
0
ファイル: ResourcesModule.cs プロジェクト: thesheps/lemonade
 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();
 }
コード例 #28
0
 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);
                         };
 }
コード例 #29
0
ファイル: Engine.cs プロジェクト: ZGoranova/OOPBasics
 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;
 }
コード例 #30
0
ファイル: FeaturesModule.cs プロジェクト: thesheps/lemonade
        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();
        }
コード例 #31
0
 protected ApiControllerBase(ICommandDispatcher commandDispatcher)
 {
     CommandDispatcher = commandDispatcher;
 }
コード例 #32
0
 public LocationController(ITwitterDataService twitterService,
                           ICommandDispatcher commandDispatcher)
 {
     _twitterService    = twitterService;
     _commandDispatcher = commandDispatcher;
 }
コード例 #33
0
 public LoginController(ILogger <LoginController> logger, ICommandDispatcher commandDispatcher)
 {
     _logger            = logger;
     _commandDispatcher = commandDispatcher;
 }
コード例 #34
0
 public ApiControllerBase(ICommandDispatcher commandDispatcher)
 {
     CommandDispatcher = commandDispatcher;
 }
コード例 #35
0
 public UsersController(ICommandDispatcher commandDispatcher, IQueryDispatcher queryDispatcher, ICurrentUserService currentUserService)
 {
     _commandDispatcher  = commandDispatcher;
     _queryDispatcher    = queryDispatcher;
     _currentUserService = currentUserService;
 }
コード例 #36
0
ファイル: UtilityController.cs プロジェクト: yayaritaa/Europa
 public UtilityController(ICommandDispatcher commands)
 {
     _commands = commands;
 }
コード例 #37
0
 public StudentsController(IQueryDispatcher queryDispatcher, ICommandDispatcher commandDispatcher)
 {
     _queryDispatcher   = queryDispatcher;
     _commandDispatcher = commandDispatcher;
 }
コード例 #38
0
 public FriendshipsModuleFacade(ICommandDispatcher commandDispatcher, IQueryDispatcher queryDispatcher)
 {
     _commandDispatcher = commandDispatcher;
     _queryDispatcher   = queryDispatcher;
 }
コード例 #39
0
 public ValuesController(ICommandDispatcher commandDispatcher)
 {
     _commandDispatcher = commandDispatcher;
 }
コード例 #40
0
 public UsersController(IUserService userService, ICommandDispatcher commandDispatcher) : base(commandDispatcher)
 {
     _userService = userService;
 }
コード例 #41
0
 public ProductsController(ICommandDispatcher commandDispatcher, IQueryDispatcher queryDispatcher)
 {
     this.commandDispatcher = commandDispatcher;
     this.queryDispatcher   = queryDispatcher;
 }
コード例 #42
0
 public AccountController(ICommandDispatcher commandDispatcher) : base(commandDispatcher)
 {
 }
コード例 #43
0
 /// <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;
 }
コード例 #44
0
        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));
 }
コード例 #46
0
        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();
            }
        }
コード例 #47
0
 public WishCompleteItemRequestHandler(ICommandDispatcher commandDispatcher) => _commandDispatcher = commandDispatcher;
コード例 #48
0
 public UpdateCurrencyController(ICommandDispatcher commandDispatcher, IQueryRunner queryRunner)
 {
     _commandDispatcher = commandDispatcher;
     _queryRunner       = queryRunner;
 }
コード例 #49
0
 /// <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));
 }
コード例 #50
0
 public LoginController(ICommandDispatcher commandDispatcher, IMemoryCache memoryCache) : base(commandDispatcher)
 {
     _memoryCache = memoryCache;
 }
コード例 #51
0
 public AddWorkoutPlanJob(ICommandDispatcher commandDispatcher)
 {
     _commandDispatcher = commandDispatcher;
 }
コード例 #52
0
 public DriverRoutesController(ICommandDispatcher commandDispatcher) : base(commandDispatcher)
 {
 }
コード例 #53
0
 /// <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)
 {
 }
コード例 #54
0
 public CommandExecuter(IQueueClient queueClient, IConfig config, IWorkerRecordStoreService workerRecordStoreService, ICommandDispatcher dispatch, IDirectCommandExecuter directCommandExecuter)
 {
     _queueClient = queueClient;
     _config      = config;
     _workerRecordStoreService = workerRecordStoreService;
     _dispatch = dispatch;
     _directCommandExecuter = directCommandExecuter;
 }
コード例 #55
0
 public LearnerMatchAndUpdate(ICommandDispatcher commandDispatcher, ILogger <LearnerMatchAndUpdate> logger)
 {
     _commandDispatcher = commandDispatcher;
     _logger            = logger;
 }
コード例 #56
0
 public CategoryController(ICommandDispatcher commandDispatcher, IQueryDispatcher queryDispatcher)
 {
     this.commandDispatcher = commandDispatcher;
     this.queryDispatcher   = queryDispatcher;
 }
コード例 #57
0
ファイル: UsersController.cs プロジェクト: Cwtttt/Passenger
 public UsersController(IUserServices userServices,
                        ICommandDispatcher commandDispatcher) : base(commandDispatcher)
 {
     _userServices = userServices;
 }
コード例 #58
0
 public FollowsController(ICommandDispatcher commandDispatcher) : base(commandDispatcher)
 {
 }
コード例 #59
0
 protected BaseController(ICommandDispatcher commandDispatcher)
 {
     CommandDispatcher = commandDispatcher;
 }
コード例 #60
0
ファイル: Dispatcher.cs プロジェクト: abibtj/LNX-S3.Common
 public Dispatcher(ICommandDispatcher commandDispatcher,
                   IQueryDispatcher queryDispatcher)
 {
     _commandDispatcher = commandDispatcher;
     _queryDispatcher   = queryDispatcher;
 }