Using Ninject with Membership.Provider

前端 未结 4 1093
刺人心
刺人心 2021-01-11 14:19

I\'m new to Ninject and I\'m having problems using it with a custom membership provider.

My membership provider has a repository interface passed in. It looks like:<

4条回答
  •  走了就别回头了
    2021-01-11 14:49

    The best solution I found was the following:

    private IRepository _repository;
    
    [Inject]
    public IRepository Repository
    {
        get { return _repository; }
        set { _repository= value; }
    }
    
    public CustomMembershipProvider()
    {
        NinjectHelper.Kernel.Inject(this);
    }
    

    Where NinjectHelper is a static helper class to get the Kernal from.

提交回复
热议问题