コード例 #1
0
        public async Task Handle(T @event)
        {
            using (var scope = MeetingsCompositionRoot.BeginLifetimeScope())
            {
                using (var connection = scope.Resolve <ISqlConnectionFactory>().GetOpenConnection())
                {
                    string type = @event.GetType().FullName;
                    var    data = JsonConvert.SerializeObject(@event, new JsonSerializerSettings
                    {
                        ContractResolver = new AllPropertiesContractResolver()
                    });

                    var sql = "INSERT INTO [meetings].[InboxMessages] (Id, OccurredOn, Type, Data) " +
                              "VALUES (@Id, @OccurredOn, @Type, @Data)";

                    await connection.ExecuteScalarAsync(sql, new
                    {
                        @event.Id,
                        @event.OccurredOn,
                        type,
                        data
                    });
                }
            }
        }
コード例 #2
0
 internal static async Task <TResult> Execute <TResult>(ICommand <TResult> command)
 {
     using (var scope = MeetingsCompositionRoot.BeginLifetimeScope())
     {
         var mediator = scope.Resolve <IMediator>();
         return(await mediator.Send(command));
     }
 }
コード例 #3
0
 internal static async Task Execute(ICommand command)
 {
     using (var scope = MeetingsCompositionRoot.BeginLifetimeScope())
     {
         var mediator = scope.Resolve <IMediator>();
         await mediator.Send(command);
     }
 }
コード例 #4
0
        private static void SubscribeToIntegrationEvents(ILogger logger)
        {
            var eventBus = MeetingsCompositionRoot.BeginLifetimeScope().Resolve <IEventsBus>();

            SubscribeToIntegrationEvent <MeetingGroupProposalAcceptedIntegrationEvent>(eventBus, logger);
            SubscribeToIntegrationEvent <PaymentRegisteredIntegrationEvent>(eventBus, logger);
            SubscribeToIntegrationEvent <NewUserRegisteredIntegrationEvent>(eventBus, logger);
        }
コード例 #5
0
        public async Task <TResult> ExecuteQueryAsync <TResult>(IQuery <TResult> query)
        {
            using (var scope = MeetingsCompositionRoot.BeginLifetimeScope())
            {
                var mediator = scope.Resolve <IMediator>();

                return(await mediator.Send(query));
            }
        }