コード例 #1
0
ファイル: AdminLog.cs プロジェクト: Mattias1/ddd-draughts
 public static AdminLog EditRoleLog(IIdPool idPool, IClock clock, AuthUser actor, RoleId roleId, string rolename)
 {
     return(new AdminLog(
                Next(idPool), "role.edit", Params(roleId, rolename),
                actor.Id, actor.Username,
                Permissions.EditRoles, clock.UtcNow()
                ));
 }
コード例 #2
0
        public (Game game, GameState gameState) BuildGame(
            IIdPool idPool, GameSettings settings, UserInfo creator, Color creatorColor)
        {
            var nextGameId = new GameId(idPool.NextForGame());
            var game       = new Game(nextGameId, settings, _clock.UtcNow());
            var gameState  = GameState.InitialState(game.Id, settings.BoardSize);

            var player = BuildPlayer(idPool, creator, creatorColor);

            game.JoinGame(player, _clock.UtcNow());

            return(game, gameState);
        }
コード例 #3
0
        public AuthUser CreateAuthUser(IIdPool idPool, Role pendingRegistrationRole,
                                       string?name, string?email, string?plaintextPassword)
        {
            if (pendingRegistrationRole.Rolename != Role.PENDING_REGISTRATION_ROLENAME)
            {
                throw new ArgumentException("You're supposed to add the pending registration role.",
                                            nameof(pendingRegistrationRole));
            }

            var nextUserId   = new UserId(idPool.NextForUser());
            var username     = new Username(name);
            var passwordHash = PasswordHash.Generate(plaintextPassword, nextUserId, username);

            return(new AuthUser(nextUserId, username, passwordHash, new Email(email), _clock.UtcNow(),
                                new[] { pendingRegistrationRole.Id }));
        }
コード例 #4
0
        public Player BuildPlayer(IIdPool idPool, UserInfo user, Color color)
        {
            var nextPlayerId = new PlayerId(idPool.Next());

            return(new Player(nextPlayerId, user.Id, user.Username, user.Rank, color, _clock.UtcNow()));
        }
コード例 #5
0
 public DefaultEntityFactory(IIdPool idPool, IComponentDatabase componentDatabase, IComponentTypeLookup componentTypeLookup)
 {
     IdPool              = idPool;
     ComponentDatabase   = componentDatabase;
     ComponentTypeLookup = componentTypeLookup;
 }
コード例 #6
0
ファイル: AdminLog.cs プロジェクト: Mattias1/ddd-draughts
 private static AdminLogId Next(IIdPool idPool) => new AdminLogId(idPool.Next());
コード例 #7
0
 public DefaultEntityFactory(IIdPool idPool, IComponentRepository componentRepository)
 {
     IdPool = idPool;
     ComponentRepository = componentRepository;
 }