首页 > 解决方案 > 转换为 Lamar - 注册 - 使用 StructureMap 的这段代码的等价物是什么?

问题描述

我正在将 ASP.NET 应用程序迁移到 .NET5 并遇到以下使用 StructureMap 的代码...

For<ICache>().AlwaysUnique().Singleton().HttpContextScoped().Add<RedisCache>()

我们在新应用程序中使用 Lamar;替换的等效代码是.AlwaysUnique().Singleton().HttpContextScoped()什么?

标签: .netlamar

解决方案


在与 Jeremy Miller(Lamar 的作者)进行了一些交流后,他确认最后一个获胜,在这种情况下,它将是 HttpContextScoped(或 Lamar 中的 Scoped)。


推荐阅读