在我的Asp.Net Web API应用程序中,我使用Simple Injector作为IoC容器。它正在解决其他控制器的依赖关系。但是我遇到了默认AccountController依赖项的问题。
private static void ConfigureTypes(Container container)
{
container.Register<Data.Contracts.Repositories.IProfileRepository,
Data.Repositories.ProfileRepository>(Lifestyle.Transient);
}
public static void Configure()
{
var container = new Container();
container.Options.DefaultScopedLifestyle = new WebApiRequestLifestyle();
ConfigureTypes(container);
var config = GlobalConfiguration.Configuration;
container.RegisterWebApiControllers(config);
container.Verify();
config.DependencyResolver = new SimpleInjectorWebApiDependencyResolver(container);
}
我该怎么做才能解决AccountController的依赖关系。这是AccountController的默认和参数化构造函数:
public AccountController()
{
}
public AccountController(ApplicationUserManager userManager,
ISecureDataFormat<AuthenticationTicket> accessTokenFormat)
{
UserManager = userManager;
AccessTokenFormat = accessTokenFormat;
}