Exemplo n.º 1
0
        private RandomWordsService InitializeService()
        {
            PancakeConfiguration pancakeConfiguration = new PancakeConfiguration
            {
                DBConnectionString = "Host=localhost;Database=Words;Username=postgres;Password=marshmallow"
            };
            RandomWordsService randomWordsService = new RandomWordsService();

            randomWordsService.Init(pancakeConfiguration);
            return(randomWordsService);
        }
Exemplo n.º 2
0
        private PancakeContext _db; //todo: подключение должно быть одно на все сервисы?

        public void Init(PancakeConfiguration configuration)
        {
            try
            {
                _db           = new PancakeContext(configuration);
                IsInitialized = true;
            }
            catch (Exception e)
            {
                Console.WriteLine($"Error connecting to database: {e}");
                throw;
            }
        }
Exemplo n.º 3
0
 public void Init(PancakeConfiguration configuration)
 {
     if (!IsInitialized)
     {
         try
         {
             _db           = new PancakeContext(configuration);
             IsInitialized = true;
         }
         catch (Exception e)
         {
             Console.WriteLine($"Error connecting to database: {e}");
             throw;
         }
     }
     else
     {
         Console.WriteLine($"RandomWordsService already initialized!");
     }
 }
Exemplo n.º 4
0
 public PancakeContext(PancakeConfiguration pancakeConfiguration)
 {
     _connectionString = pancakeConfiguration.DBConnectionString;
 }