static Settings() { var configurationRoot = GetConfigurationRoot(Build.Environment); Elastic = configurationRoot.GetSection(ElasticSettings.Key).Get <ElasticSettings>(); Postgres = configurationRoot.GetSection(PostgresSettings.Key).Get <PostgresSettings>(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var postgresSection = Configuration.GetSection("Postgresql"); postgresSettings = postgresSection.Get <PostgresSettings>(); services.AddScoped <IStorageRepository, StorageRepository>(); services.AddLocalization(options => options.ResourcesPath = "Resources"); services.AddMvc() .SetCompatibilityVersion(CompatibilityVersion.Version_2_2) .AddViewLocalization(); services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie(options => { options.LoginPath = new PathString("/Account/Login"); }); if (postgresSettings != null && postgresSettings.ConnectionString != null) { services.AddSingleton(postgresSettings); } }
public MartenAdapter(PostgresSettings settings) { _settings = settings; CreateDatabase(); DocumentStore = DocumentStore.For(Configure); }
public void ConfigureContainer(ServiceRegistry services) { var twitterSettings = Configuration.GetSection("Twitter").Get <TwitterSettings>(); services.For <TwitterSettings>().Use(x => twitterSettings); var instanceSettings = Configuration.GetSection("Instance").Get <InstanceSettings>(); services.For <InstanceSettings>().Use(x => instanceSettings); var dbSettings = Configuration.GetSection("Db").Get <DbSettings>(); services.For <DbSettings>().Use(x => dbSettings); var logsSettings = Configuration.GetSection("Logging").Get <LogsSettings>(); services.For <LogsSettings>().Use(x => logsSettings); if (string.Equals(dbSettings.Type, DbTypes.Postgres, StringComparison.OrdinalIgnoreCase)) { var connString = $"Host={dbSettings.Host};Username={dbSettings.User};Password={dbSettings.Password};Database={dbSettings.Name}"; var postgresSettings = new PostgresSettings { ConnString = connString }; services.For <PostgresSettings>().Use(x => postgresSettings); services.For <ITwitterUserDal>().Use <TwitterUserPostgresDal>().Singleton(); services.For <IFollowersDal>().Use <FollowersPostgresDal>().Singleton(); services.For <IDbInitializerDal>().Use <DbInitializerPostgresDal>().Singleton(); } else { throw new NotImplementedException($"{dbSettings.Type} is not supported"); } services.For <ITwitterUserService>().DecorateAllWith <CachedTwitterUserService>(); services.For <ITwitterUserService>().Use <TwitterUserService>().Singleton(); services.Scan(_ => { _.Assembly("BirdsiteLive.Twitter"); _.Assembly("BirdsiteLive.Domain"); _.Assembly("BirdsiteLive.DAL"); _.Assembly("BirdsiteLive.DAL.Postgres"); _.Assembly("BirdsiteLive.Pipeline"); _.TheCallingAssembly(); //_.AssemblyContainingType<IDal>(); //_.Exclude(type => type.Name.Contains("Settings")); _.WithDefaultConventions(); _.LookForRegistries(); }); }
public PostgresTestingBase() { _settings = new PostgresSettings { ConnString = "Host=127.0.0.1;Username=postgres;Password=mysecretpassword;Database=mytestdb", DbVersionTableName = "DbVersionTableName" + RandomGenerator.GetString(4), CachedTweetsTableName = "CachedTweetsTableName" + RandomGenerator.GetString(4), FollowersTableName = "FollowersTableName" + RandomGenerator.GetString(4), TwitterUserTableName = "TwitterUserTableName" + RandomGenerator.GetString(4), }; _tools = new PostgresTools(_settings); }
public DbManager(string connectionString = null) { var postgresSettings = new PostgresSettings(); if (connectionString != null) { postgresSettings.PostgresConnectionString = connectionString; } DataConnection.DefaultSettings = postgresSettings; UpgradeDatabase(postgresSettings.PostgresConnectionString); }
public Container Init() { var container = new Container(x => { x.For <DbSettings>().Use(x => _dbSettings); x.For <InstanceSettings>().Use(x => _instanceSettings); if (string.Equals(_dbSettings.Type, DbTypes.Postgres, StringComparison.OrdinalIgnoreCase)) { var connString = $"Host={_dbSettings.Host};Username={_dbSettings.User};Password={_dbSettings.Password};Database={_dbSettings.Name}"; var postgresSettings = new PostgresSettings { ConnString = connString }; x.For <PostgresSettings>().Use(x => postgresSettings); x.For <ITwitterUserDal>().Use <TwitterUserPostgresDal>().Singleton(); x.For <IFollowersDal>().Use <FollowersPostgresDal>().Singleton(); x.For <IDbInitializerDal>().Use <DbInitializerPostgresDal>().Singleton(); } else { throw new NotImplementedException($"{_dbSettings.Type} is not supported"); } var serviceProvider = new ServiceCollection().AddHttpClient().BuildServiceProvider(); x.For <IHttpClientFactory>().Use(_ => serviceProvider.GetService <IHttpClientFactory>()); x.For(typeof(ILogger <>)).Use(typeof(DummyLogger <>)); x.Scan(_ => { _.Assembly("BirdsiteLive.Twitter"); _.Assembly("BirdsiteLive.Domain"); _.Assembly("BirdsiteLive.DAL"); _.Assembly("BirdsiteLive.DAL.Postgres"); _.Assembly("BirdsiteLive.Moderation"); _.TheCallingAssembly(); _.WithDefaultConventions(); _.LookForRegistries(); }); }); return(container); }
public DbManager(string messagesPath, string ownerName, string newImagesPath = null, string connectionString = null) { var postgresSettings = new PostgresSettings(); if (connectionString != null) { postgresSettings.PostgresConnectionString = connectionString; } DataConnection.DefaultSettings = postgresSettings; UpgradeDatabase(postgresSettings.PostgresConnectionString); _loader = new Loader(messagesPath, newImagesPath); _ownerName = ownerName; InsertOwner(); }
public void ConfigureServices(IServiceCollection services) { var postgresSection = Configuration.GetSection("Postgres"); postgresSettings = postgresSection.Get <PostgresSettings>(); var routesSection = Configuration.GetSection("Routes"); routesSettings = routesSection.Get <RoutesSettings>(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); services.AddScoped <IResultRepository, ResultRepository>(); if (postgresSettings != null && postgresSettings.ConnectionString != null) { services.AddSingleton(postgresSettings); } if (routesSettings != null && routesSettings.GetDataAddress != null) { services.AddSingleton(routesSettings); } }
public void Setup() { _memstateSettings = new EngineSettings(); _settings = new PostgresSettings(); }
protected PostgresBase(PostgresSettings settings) { _settings = settings; }
public MartenHealthCheck(IServiceProvider serviceProvider, PostgresSettings postgresSettings, ILogger <MartenHealthCheck> logger) { _serviceProvider = serviceProvider; _postgresSettings = postgresSettings; _logger = logger; }
public TwitterUserPostgresDal(PostgresSettings settings) : base(settings) { }
public ResultRepository(PostgresSettings settings) { this.settings = settings; }
public PostgresTools(PostgresSettings settings) { _settings = settings; }
public CachedTweetsPostgresDal(PostgresSettings settings) : base(settings) { }
public DbInitializerPostgresDal(PostgresSettings settings, PostgresTools tools) : base(settings) { _tools = tools; }
public DbMigrator(PostgresSettings settings) { this.settings = settings; }
public StorageRepository(PostgresSettings settings) { this.settings = settings; }
public static IServiceCollection IncludePostgres <T>(this IServiceCollection services, PostgresSettings postgresSettings, PostgresContextSettings postgresContextSettings, bool shouldAddEntityFrameworkNpgsql = false) where T : DbContext { postgresSettings.AddContextSettings(postgresContextSettings); services .AddScoped(provider => postgresSettings) .AddDbContext <T>(options => options.UseNpgsql(postgresSettings.ConnectionString)); if (shouldAddEntityFrameworkNpgsql) { services.AddEntityFrameworkNpgsql(); } return(services); }
public FollowersPostgresDal(PostgresSettings settings) : base(settings) { }