开发者

Parameterless implementation for Ninject mappings

i am creating custom membership provider using ninject for binding to sql classes.

my class in looks like

public MyMembershipProvider(IUsersRepository userRepository)
{
   this.userRepository = userRepository;
}
开发者_开发问答

How can i create from this parameterless constructor?


kernel.Bind<IUsersRepository>().To<UsersRepository>();
kernel.Bind<MembershipProvider>().To<MyMembershipProvider>();

and then:

public class AccountController : Controller
{
    private readonly MembershipProvider _membershipProvider;
    public AccountController(MembershipProvider membershipProvider)
    {
        _membershipProvider = membershipProvider;
    }

    public ActionResult Foo()
    {
        // TODO: Use the membership provider to do some processing
        return View();
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜