1

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");
           userRepository = __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?

Bo Persson
  • 90,663
  • 31
  • 146
  • 203
Paul
  • 12,359
  • 20
  • 64
  • 101

2 Answers2

1

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

Laurel
  • 5,965
  • 14
  • 31
  • 57
Seif Attar
  • 632
  • 3
  • 9
0

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.

autonomatt
  • 4,393
  • 4
  • 27
  • 36