I am new to dependency injection and I am trying to figure it out. Lets say I have class book :
class Book
{
public String Author { get; set; }
public String Title { get; set; }
private int Quantity {get;set;}
public Book(String aut, String pav, int qua)
{
this.Author = aut;
this.Title = pav;
this.Quantity = qua;
}
}
and then other class book with type
class BookWithType
{
public Book Book { get; set; }
public String Type { get; set; }
public BookWithType(Book book, String type)
{
this.Book = book;
this.Type = type;
}
}
Can I say that this is a dependency injection when in BookWithType constructor I inject Book object?
You wouldn't create a dependency injection with a data transfer object. It would be more like:
Then some kind of display layer like:
Where IBookRetriever...