I have the following problem when applying the SimpleInjector container in a simple application:
The configuration is invalid.
The type BookAppService is directly or indirectly depending on itself.
The cyclic graph contains the following types: BookAppService -> BookAppService -> BookAppService.
This is the BookAppService class:
public class BookAppService : AppServiceBase<Book>, IBookAppService
{
private readonly IBookAppService _bookService;
public BookAppService(IBookAppService bookService) : base(bookService)
{
_bookService = bookService;
}
public IEnumerable<Book> GetSpecialBooks(IEnumerable<Book> books)
{
return _bookService.GetSpecialBooks(_bookService.GetAll());
}
And here is the SimpleInjectorInitializer configuration:
container.Register(typeof(IAppServiceBase<>), typeof(AppServiceBase<>));
container.Register<IBookAppService, BookAppService>(Lifestyle.Scoped);
I'm a good beginner in IoC and DI, and thank you for any help and tips. Thank you.