Tôi đang sử dụng Ninject như IoC của tôi và tôi đã viết một nhà cung cấp vai trò như sau:Ninject với 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 */
}
Tôi đọc mà Provider
lớp được khởi tạo trước khi Ninject được để tiêm dụ. Làm thế nào để tôi đi xung quanh điều này? Tôi hiện có mã số ninject này:
Bind<RoleProvider>().To<BasicRoleProvider>().InRequestScope();
Từ câu trả lời này 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.
Tôi không hiểu điều này.
bản sao có thể có của [Tiêm kho lưu trữ với nhà cung cấp tư cách thành viên tùy chỉnh với Ninject] (http://stackoverflow.com/questions/5596441/inject-repository-to-custom-membership-provider-with-ninject) –