我们正在从StructureMap迁移到Lamar,但我找不到“Lamar版本”以便在运行时传递参数。
我们有一个需要字符串参数(伪代码)的类:
我们有一个需要字符串参数(伪代码)的类:
public class MyRepository {
public MyRepository(string accountId) {}
}
...和工厂
public class MyRepoFactory(Container container) {
public MyRepository GetRepositoryForAccount(string accountId) =>
container
// With() is not available in Lamar?
.With("accountId").EqualTo(accountId)
.GetInstance<IMyRepository>();
}
实际上还有其他依赖关系。
如何说Lamar使用IMyRepository
的GetInstance()
方法,并为构造函数参数accountId
使用值xy?