简单注入器 - 部分 class 注入

Simple Injector - Partial class injection

如何使用部分 class 配置注入??

container.RegisterPerWebRequest<IDataContextAsync, DataBaseContext>();
container.RegisterPerWebRequest<IStoredProcedureContext, DataBaseContext>();

我的代码:

public partial class DataBaseContext : DataContext
public partial class DataBaseContext : IStoredProcedureContext

错误:

-[Torn Lifestyle] The registration for IStoredProcedureContext maps to the same implementation and lifestyle as the registration for IDataContextAsync does. They both map to DataBaseContext (Web Request). This will cause each registration to resolve to a different instance: each registration will have its own instance during a single Web Request. See the Error property for detailed information about the warnings. Please see https://simpleinjector.org/diagnostics how to fix problems and how to suppress individual warnings.

here

var container = new Container();
container.Options.DefaultScopedLifestyle = new WebRequestLifestyle();

var registration = Lifestyle.Scoped.CreateRegistration<DataBaseContext>(container);
container.AddRegistration(typeof(IStoredProcedureContext), registration);

container.Verify();