July 2019
Intermediate to advanced
410 pages
10h 32m
English
To illustrate .Net Core's DI, we need to make some modifications to the FlixOne inventory management application. The first thing to do will be to update the InventoryContext class, which was defined earlier, in order to no longer implement the Singleton pattern (as we will do this using .Net Core's DI):
public class InventoryContext : IInventoryContext{ public InventoryContext() { _books = new ConcurrentDictionary<string, Book>(); } private readonly static object _lock = new object(); private readonly IDictionary<string, Book> _books; public Book[] GetBooks() { return _books.Values.ToArray(); } ...}
The detail of the AddBook and UpdateQuantity methods are shown in the following code:
public bool AddBook(string name){ _books.Add(name, ...Read now
Unlock full access