September 2013
Intermediate to advanced
142 pages
2h 58m
English
In Chapter 1, Understanding Dependency Injection, we implemented DI manually in the MailService class. You remember that we ignored the configuration of SmtpClient to simplify the project. Now, we are going to add the configuration of SmtpClient and implement DI using Ninject.
Let's start by creating the
MailConfig class:
class MailServerConfig { public string SmtpServer { get { return ConfigurationManager.AppSettings["SmtpServer"]; } } public int SmtpPort { get { var port = ConfigurationManager .AppSettings["SmtpPort"]; return Convert.ToInt32(port); } } public string SenderEmail { get { return ConfigurationManager .AppSettings["SenderEmail"]; } } public string SenderPassword { get { return ConfigurationManager .AppSettings["SenderPassword"]; ...Read now
Unlock full access