我的项目有以下结构:
firstProj
|
+--- src
| |
| +--- Repositories
| |
| +--- MyFirstRepository.cs
| +--- IMyFirstRepository.cs
|
secondProj
|
+--- src
|
+--- Repositories
|
+--- MySecondRepository.cs
+--- IMySecondRepository.cs firstProject包含一个Startup.cs文件,该文件具有以下内容:
services.Scan(scan => scan
.FromEntryAssembly()
.AddClasses(classes => classes
.InNamespaces("my.namespaces"))
.UsingRegistrationStrategy(RegistrationStrategy.Replace(ReplacementBehavior.ImplementationType))
.AsImplementedInterfaces()
.WithScopedLifetime());第一个存储库被识别并添加到池中,但是第二个存储库没有识别。这两个存储库都位于my.namespace命名空间下,如果我手动添加第一个文件:
services.AddScoped<IMyFirstRepository, MyFirstRepository>()它起作用了。对如何让Scrutor扫描所有文件有什么想法吗?
发布于 2022-06-02 07:29:00
尝尝这个
builder.Services.Scan(scan =>
scan.FromAssemblies()
.AddClasses(classes => classes.InNamespaces("Repositories"))
.AsSelf()
.WithScopedLifetime());https://stackoverflow.com/questions/72013807
复制相似问题