Я использую Ninject как мой IoC, и я написал поставщик ролей следующим образом:Ninject with MembershipProvider | RoleProvider
public class BasicRoleProvider : RoleProvider
{
private IAuthenticationService authenticationService;
public BasicRoleProvider(IAuthenticationService authenticationService)
{
if (authenticationService == null) throw new ArgumentNullException("authenticationService");
this.authenticationService = authenticationService;
}
/* Other methods here */
}
Я читал, что Provider
классов получить экземпляр, прежде чем Ninject получает впрыснуть экземпляр. Как мне обойти это? В настоящее время у меня есть этот код ninject:
Bind<RoleProvider>().To<BasicRoleProvider>().InRequestScope();
От этого ответа here.
If you mark your dependencies with [Inject] for your properties in your provider class, you can call kernel.Inject(MemberShip.Provider) - this will assign all dependencies to your properties.
Я не понимаю этого.
Возможный дубликат [Inject репозиторий для пользовательского поставщика членства с Ninject] (http://stackoverflow.com/questions/5596441/inject-repository-to-custom-membership-provider-with-ninject) –