Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class EmailAccessor : IEmailAccessor
- {
- private string senderEmail;
- private string senderUsername;
- private string senderPassword;
- private int port;
- public EmailAccessor(string senderEmail, string senderUsername, string senderPassword, int port)
- {
- this.senderEmail = senderEmail;
- this.senderUsername = senderUsername;
- this.senderPassword = senderPassword;
- this.port = port;
- }
- //...
- }
- public class NotificationEngine : INotificationEngine
- {
- private IEmailAccessor emailAccessor;
- public NotificationEngine(IEmailAccessor emailAccessor)
- {
- this.emailAccessor = emailAccessor;
- }
- //...
- }
- [RoutePrefix("api/email")]
- public class EmailController : ApiController
- {
- private INotificationEngine notificationEngine;
- public EmailController(INotificationEngine notificationEngine)
- {
- this.notificationEngine = notificationEngine;
- }
- [HttpPost]
- [Route("send")]
- public void Post([FromBody] EmailNotification email)
- {
- //...
- }
- //...
- }
- public static class UnityConfig
- {
- public static void RegisterTypes(IUnityContainer container)
- {
- container.LoadConfiguration();
- //...
- container.RegisterType<IEmailAccessor, EmailAccessor>(new InjectionConstructor(
- ConfigurationManager.AppSettings["SenderEmail"],
- ConfigurationManager.AppSettings["SenderUsername"],
- ConfigurationManager.AppSettings["SenderPassword"],
- int.Parse(ConfigurationManager.AppSettings["Port"])));
- container.RegisterType<INotificationEngine, NotificationEngine>();
- DependencyResolver.SetResolver(new UnityDependencyResolver(container));
- }
- }
- {
- "Message": "No HTTP resource was found that matches the request URI 'http://localhost:63855/api/email/send'.",
- "MessageDetail": "No type was found that matches the controller named 'email'."
- }
Add Comment
Please, Sign In to add comment