コード例 #1
0
        protected async Task AddEventAsync(
            NpgsqlConnectionFactory connectionFactory,
            GameId gameId,
            GameEvent gameEvent)
        {
            var gameEventStore = new PostgresGameEventStore(connectionFactory);

            await gameEventStore.AddEventAsync(gameId, gameEvent, CancellationToken.None);
        }
コード例 #2
0
        public ILogMaintainer Create(string connectionString, PHmiModel.Entities.Log log, ITimeService timeService)
        {
            var npgsqlConnectionFactory = new NpgsqlConnectionFactory(connectionString);
            var logRepository           = new LogRepository(log.Id);

            using (var connection = npgsqlConnectionFactory.Create())
            {
                logRepository.EnsureTable(connection);
            }
            return(new LogMaintainer(
                       log,
                       logRepository,
                       timeService,
                       npgsqlConnectionFactory));
        }
コード例 #3
0
        private static DbConnection BuildConnection(IConnectionSettings connectionSettings)
        {
            if (null == connectionSettings)
            {
                connectionSettings = ConnectionSettings;
            }

            switch (connectionSettings.ProviderInvariantName)
            {
            case DataConfiguration.SqlServerCompactProviderInvariantName:
            {
                var connectionFactory =
                    new SqlCeConnectionFactory(DataConfiguration.SqlServerCompactProviderInvariantName);
                return(connectionFactory.CreateConnection(connectionSettings.ConnectionString));
            }

            case DataConfiguration.SqlServerProviderInvariantName:
            {
                var connectionFactory = new SqlConnectionFactory();
                return(connectionFactory.CreateConnection(connectionSettings.ConnectionString));
            }

            case DataConfiguration.MySqlProviderInvariantName:
            {
                var connectionFactory = new MySqlConnectionFactory();
                return(connectionFactory.CreateConnection(connectionSettings.ConnectionString));
            }

            case DataConfiguration.PostgreSqlProviderInvariantName:
            {
                var connectionFactory = new NpgsqlConnectionFactory();
                return(connectionFactory.CreateConnection(connectionSettings.ConnectionString));
            }

            case DataConfiguration.OracleDBProviderInvariantName:
            {
                var connectionFactory = new OracleConnectionFactory();
                return(connectionFactory.CreateConnection(connectionSettings.ConnectionString));
            }

            default:
                throw new InvalidOperationException("connectionSettings.ProviderInvariantName == " +
                                                    connectionSettings.ProviderInvariantName);
            }
        }
コード例 #4
0
        protected async Task <GameId> CreateGameAsync(
            NpgsqlConnectionFactory connectionFactory,
            NewPlayer?player1 = null,
            NewPlayer?player2 = null)
        {
            var gameStore = new PostgresGameStore(connectionFactory);

            var newGame = new NewGame(
                players: new PlayerList(
                    randomFirstPlayer: false,
                    player1 ?? new NewPlayer(Player1, PlayerType.User),
                    player2 ?? new NewPlayer(Player2, PlayerType.User)),
                firstPlayerIndex: 0,
                seed: new Seed(42),
                boardType: BoardType.OneEyedJack,
                numSequencesToWin: 2);

            return(await gameStore.PersistNewGameAsync(newGame, CancellationToken.None));
        }
コード例 #5
0
        public IAlarmsRunTarget Create(string connectionString, IProject project, AlarmCategory alarmCategory, ITimeService timeService)
        {
            var npgsqlConnectionFactory = new NpgsqlConnectionFactory(connectionString);
            var alarmsRepository        = new AlarmsRepository(alarmCategory.Id);

            using (var connection = npgsqlConnectionFactory.Create())
            {
                alarmsRepository.EnsureTable(connection);
            }
            return(new AlarmsRunTarget(
                       alarmCategory,
                       new NotificationReporter(timeService)
            {
                LifeTime = TimeSpan.FromTicks(0)
            },
                       alarmsRepository,
                       project,
                       timeService,
                       npgsqlConnectionFactory));
        }
コード例 #6
0
        public ITrendsRunTarget Create(string connectionString, IProject project, TrendCategory trendCategory, ITimeService timeService)
        {
            var npgsqlConnectionFactory = new NpgsqlConnectionFactory(connectionString);
            var repositoryFactory       = new TrendsRepositoryFactory(
                npgsqlConnectionFactory,
                trendCategory.Id,
                trendCategory.TrendTags.Select(t => t.Id).ToArray());

            using (var repository = repositoryFactory.Create())
            {
                repository.EnsureTables();
            }

            return(new TrendsRunTarget(
                       trendCategory,
                       new NotificationReporter(timeService)
            {
                LifeTime = TimeSpan.FromTicks(0)
            },
                       repositoryFactory,
                       project,
                       timeService,
                       new TrendTableSelector()));
        }
コード例 #7
0
 public PostgresGameEventStore(NpgsqlConnectionFactory connectionFactory)
 {
     _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory));
 }
コード例 #8
0
 public PostgresSimulationStore(NpgsqlConnectionFactory connectionFactory)
 {
     _connectionFactory = connectionFactory;
 }
コード例 #9
0
 public PostgresGameStore(NpgsqlConnectionFactory connectionFactory)
 {
     _connectionFactory = connectionFactory;
 }
コード例 #10
0
 public PostgresGameListProvider(NpgsqlConnectionFactory connectionFactory)
 {
     _connectionFactory = connectionFactory;
 }