My First DI Application
We start our example with a service class in which the concerns are not separated. Then we will improve maintainability step-by-step, by first separating concerns and then programming to interface in order to make our modules loosely coupled. At the final point, we will have our first DI application. The source code for all the examples of this book is available for download on the publisher's website.
The main responsibility of this service is to send an e-mail using the information provided. In order to make the example simple and clear, client initialization is omitted.
class MailService { public void SendEmail(string address, string subject, string body) { var mail = new MailMessage(); mail.To.Add(address); mail.Subject ...
Get Mastering Ninject for Dependency Injection now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.