当前位置: 首页>>代码示例>>C#>>正文


C# IEventPublisher.Publish方法代码示例

本文整理汇总了C#中IEventPublisher.Publish方法的典型用法代码示例。如果您正苦于以下问题:C# IEventPublisher.Publish方法的具体用法?C# IEventPublisher.Publish怎么用?C# IEventPublisher.Publish使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IEventPublisher的用法示例。


在下文中一共展示了IEventPublisher.Publish方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CommandVersioningHandlerModule

        public CommandVersioningHandlerModule(IEventPublisher publisher)
        {
            For<CommandMessage<CreateTShirtV2>>()
                .Handle((_, __) => { throw new NotSupportedException(); });

            For<CommandMessage<CreateTShirtV3>>()
                .Handle((commandMessage, ct) =>
                {
                    var command = new CreateTShirtV4
                    {
                        Name = commandMessage.Command.Name,
                        Sizes = commandMessage.Command.Sizes,
                        Colors = commandMessage.Command.Colors,
                        BlankType = "Round"
                    };
                    var upconvertedCommand = new CommandMessage<CreateTShirtV4>(
                        commandMessage.CommandId,
                        commandMessage.RequestUser, 
                        command);
                    return this.DispatchSingle(upconvertedCommand, ct);
                });

            For<CommandMessage<CreateTShirtV4>>()
                .Handle((commandMessage, ct) =>
                {
                    publisher.Publish(new TShirtCreatedV4
                    {
                        BlankType = commandMessage.Command.BlankType,
                        Name = commandMessage.Command.Name,
                        Colors = commandMessage.Command.Colors,
                        Sizes = commandMessage.Command.Sizes
                    });
                    return Task.FromResult(true);
                });
        }
开发者ID:dennisdoomen,项目名称:Cedar,代码行数:35,代码来源:CommandVersioningHandlerModule.cs

示例2: ProcessOrder

 public void ProcessOrder(Order order, IEventPublisher eventPublisher)
 {
     if (Equals(order.ServiceType, ServiceType.Delivery))
     {
         eventPublisher.Publish(new OrderNeedsDelivery(this));
     }
 }
开发者ID:montereytree,项目名称:DDDPizzaInc,代码行数:7,代码来源:Order.cs

示例3: WhenIIssueACreateElectionCommand

        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();
        }
开发者ID:rmacdonaldsmith,项目名称:CQRS-MassTransit,代码行数:30,代码来源:CreateElectionSteps.cs


注:本文中的IEventPublisher.Publish方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。