我正在尝试将此存储库从 Guice 移植到 Scaldi。我在/app/utils/di/SilhouetteModule.scala(第 60-65 行)的代码中堆叠:
Map(
credentialsProvider.id -> credentialsProvider,
facebookProvider.id -> facebookProvider,
googleProvider.id -> googleProvider,
twitterProvider.id -> twitterProvider
),
这就是我现在的位置
class SilhouetteModule extends Module {
bind[DelegableAuthInfoDAO[PasswordInfo]] to new PasswordInfoDAO
bind[DelegableAuthInfoDAO[OAuth1Info]] to new OAuth1InfoDAO
bind[DelegableAuthInfoDAO[OAuth2Info]] to new OAuth2InfoDAO
bind[CacheLayer] to new PlayCacheLayer
bind[HTTPLayer] to new PlayHTTPLayer
bind[IDGenerator] to new SecureRandomIDGenerator
bind[PasswordHasher] to new BCryptPasswordHasher
bind[EventBus] to new EventBus
bind[Environment[User, CachedCookieAuthenticator]] toProvider new Environment[User, CachedCookieAuthenticator](
inject [UserService],
inject [AuthenticatorService],
// **this is where I don't know what to do**
Map(
credentialsProvider.id -> credentialsProvider,
facebookProvider.id -> facebookProvider,
googleProvider.id -> googleProvider,
twitterProvider.id -> twitterProvider
),
inject [EventBus]
)
//... *Provider bindings below
我该怎么做才能像上面的代码一样注入 Map?
Scaldi 可以绑定到函数(如 Guice 中的 @Provides 注释)吗?
谢谢