コード例 #1
0
ファイル: DemoHostMember.cs プロジェクト: MrAntix/gang
        protected override async Task OnCommandExecutedAsync(
            IGangCommand command,
            GangState <HostState> state
            )
        {
            await base.OnCommandExecutedAsync(command, state);

            if (!state.HasErrors)
            {
                state = state.AddResult(
                    command.Audit.MemberId,
                    new GangNotify(
                        id: command.GetTypeName(),
                        type: GangNotificationTypes.Success,
                        data: new
                {
                    type = command.GetTypeName(),
                    data = command.Data
                }
                        )
                    );
            }

            var results = state.GetResults(command.Audit);

            foreach (var result in results)
            {
                await Controller.SendCommandAsync(
                    result.Command,
                    result.SendToMemberIds,
                    command.Audit.Version
                    );
            }
        }
コード例 #2
0
ファイル: GangCommandExecutor.cs プロジェクト: MrAntix/gang
        async Task <GangState <TStateData> > IGangCommandExecutor <TStateData>
        .ExecuteAsync(GangState <TStateData> state, IGangCommand command)
        {
            var dataTypeName = command.GetTypeName();

            if (!_handlers.ContainsKey(dataTypeName))
            {
                throw new GangCommandHandlerNotFoundExcetion();
            }

            var handler = _handlers[dataTypeName];

            return(await handler.HandleAsync(state, command));
        }