-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDIModule.kt
48 lines (44 loc) · 2.33 KB
/
DIModule.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package org.bibletranslationtools.fetcher.di
import org.bibletranslationtools.fetcher.config.DevEnvironmentConfig
import org.bibletranslationtools.fetcher.config.EnvironmentConfig
import org.bibletranslationtools.fetcher.impl.repository.*
import org.bibletranslationtools.fetcher.io.LocalFileTransferClient
import org.bibletranslationtools.fetcher.repository.BookCatalog
import org.bibletranslationtools.fetcher.repository.BookRepository
import org.bibletranslationtools.fetcher.repository.ChapterCatalog
import org.bibletranslationtools.fetcher.repository.DirectoryProvider
import org.bibletranslationtools.fetcher.repository.LanguageCatalog
import org.bibletranslationtools.fetcher.repository.LanguageRepository
import org.bibletranslationtools.fetcher.repository.ProductCatalog
import org.bibletranslationtools.fetcher.repository.ResourceContainerRepository
import org.bibletranslationtools.fetcher.repository.StorageAccess
import org.koin.core.qualifier.named
import org.koin.dsl.module
import org.wycliffeassociates.rcmediadownloader.io.IDownloadClient
val appDependencyModule = module(createdAtStart = true) {
val envConfig: EnvironmentConfig = when (System.getenv("ENVIRONMENT").toUpperCase()) {
"PRODUCTION" -> EnvironmentConfig()
"DEVELOPMENT" -> DevEnvironmentConfig()
else -> throw ExceptionInInitializerError("Environment type is not defined or invalid.")
}
single {
envConfig
}
single<DirectoryProvider> { DirectoryProviderImpl(get()) }
single<StorageAccess> { StorageAccessImpl(get()) }
single<ChapterCatalog> { ChapterCatalogImpl() }
single<LanguageCatalog>(named(LangType.GL.name)) { UnfoldingWordLanguagesCatalog(get(), LangType.GL) }
single<LanguageCatalog>(named(LangType.HL.name)) { UnfoldingWordLanguagesCatalog(get(), LangType.HL) }
single<LanguageCatalog>(named(LangType.ALL.name)) { UnfoldingWordLanguagesCatalog(get(), LangType.ALL) }
single<LanguageRepository> {
LanguageRepositoryImpl(
get(named(LangType.GL.name)),
get(named(LangType.HL.name))
)
}
single<ProductCatalog> { ProductCatalogImpl() }
single<BookCatalog> { BookCatalogImpl() }
single<BookRepository> { BookRepositoryImpl(get()) }
single<ResourceContainerRepository> { RCRepositoryImpl(get()) }
single<IDownloadClient> { LocalFileTransferClient(get()) }
}