Reputation: 1131
When i'm going resolve type from unity container StackOverflowException
occurs in :
public class UserValidator : Validator<User>
{
readonly IBaseService<User> _service;
public UserValidator()
{
_service = ApplicationResolver.Instance.Resolve<IBaseService<User>>();
RuleFor(user => user.Email).EmailAddress();
}
}
and BaseService
:
public BaseService(IBaseRepository<T> repository, IValidator<T> validator)
{
Repository = repository;
Validator = validator;
}
and Register
:
container.RegisterType<IValidator<User>, UserValidator>();
should I change the pattern?
Upvotes: 0
Views: 1589
Reputation: 1131
I have BaseService
depending on Validator
and Validator
depending on BaseService
.
Repository
to use store/retrieve an entity from the data store.
Upvotes: 2