public GcpObjectStorage(IObjectStorageConfiguration configuration) { var credential = GoogleCredential.FromJson(configuration.Credential); var saCredential = (ServiceAccountCredential)credential.UnderlyingCredential; _saCredential = saCredential; _storageClient = StorageClient.Create(credential); _configuration = configuration; }
public static IServiceCollection AddLocalObjectStorage(this IServiceCollection services, IObjectStorageConfiguration configuration) { services.AddSingleton <IObjectStorage, LocalObjectStorage>(sp => { return(new LocalObjectStorage(configuration)); }); return(services); }
public static IServiceCollection AddInfrastructure(this IServiceCollection services, IApplicationDbConfiguration dbConfig, IObjectStorageConfiguration objectStorageConfiguration) { services.AddDbContext <ApplicationDbContext>(options => { string provider = dbConfig.Provider; string connectionString = dbConfig.ConnectionString; switch (provider) { case "mysql": options.UseMySql(connectionString, o => { o.MigrationsAssembly(typeof(ApplicationDbContext).Assembly.FullName); }); break; default: throw new NotSupportedException("Unsupported database provider"); } }); services.AddScoped <IApplicationDbContext>(sp => sp.GetRequiredService <ApplicationDbContext>()); services.AddSingleton <IClock, SystemClock>(); switch (objectStorageConfiguration.Provider) { case "gcs": services.AddGcpObjectStorage(objectStorageConfiguration); break; case "local": services.AddLocalObjectStorage(objectStorageConfiguration); break; default: throw new NotSupportedException("Unsupported storage provider"); } return(services); }
public LocalObjectStorage(IObjectStorageConfiguration configuration) { _configuration = configuration; }