I am designing an application with the following layers
- Data Layer(w/ generic repository on top of EF 4.1 )
- Service Layer - all business logic goes here
- ASP.NET MVC 3 website and ServiceStack.NET web services
I am trying to implement a custom membership provider to leverage my service/repositories
My initial though was to call the service layer methods from within the provider but, of course, I can not use DI(via Ninject) as the Membership is handled by the framework and prevents me from using constructor injection.
I have tried instantiating an instance of my UserService class within the initialize method in the provider via:
userService = (UserService)Activator.CreateInstance(typeof(UserService));
But given that user service depends on a repository being injected by Ninject, this does not work as the repo never gets injected.
What am I missing here? what is the easiest way to get around this issue? Should I be coming at this from an entire different angle?
EDIT: Here is my user service as requested
public class UserService : IUserService
{
private readonly IUserRepository userRepository;
private readonly IUnitOfWork unitOfWork;
public UserService(IUserRepository userRepository, IUnitOfWork unitOfWork)
{
this.userRepository = userRepository;
this.unitOfWork = unitOfWork;
}
//methods(AddUser, etc.)...
}