S#arp Architecture :: IoC with Custom MembershipProvider
I´m using the lastest S#arp Architecture version...
In my project, I´m implementing a Custom MembershipProvider...
First question, Where is the right place to put it? I choose Core project...
Second question, How work IoC with custom MembershipProvider?
Here is my code :
public class AdminMemberProvider : MembershipProvider
{
...
private readonly IRepository<Customer> userRepository;
public AdminMemberProvider(IRepository<Customer> __userRepository)
{
Check.Require(__userRepository != null, "userRepository may not be null");
u开发者_开发知识库serRepository = __userRepository;
}
...
}
public class AdminRoleProvider : RoleProvider
{
private readonly IRepository<Customer> userRepository;
public AdminRoleProvider(IRepository<Customer> __userRepository): base()
{
Check.Require(__userRepository != null, "userRepository may not be null");
userRepository = __userRepository;
}
...
}
When I tried to execute my project I got the error:
Parser Error Message: No parameterless constructor defined for this object.
<add name="AdminRoleProvider" type="MalCat.Shop.Core.Membership.AdminRoleProvider, MalCat.Shop.Core" />
Should the IoC not handle this ? What am I supposed to do to fix that?
I am not sure about the first question, to me it doesn't feel it belongs in core(if I am not mistaken the membership provider is in System.Web), I would put it with a web related project.
The second question has been discussed before on the sharp architecture group, perhaps this thread will be of use: https://groups.google.com/forum/#!forum/sharp-architecture
Mauricio Scheffer wrote a blog post about this recently: http://bugsquash.blogspot.com/2010/11/windsor-managed-membershipproviders.html
I would put it in the Service Layer (ApplicationServices). It is a service after all. And it will make use of your UserRepositories in the Data Layer.
精彩评论