public RazorMailTemplateEngine(RazorTemplatesFactory templatesFactory, bool autoReloadTemplates) { _templatesFactory = templatesFactory; if (autoReloadTemplates) { _folderChangedTrigger = new FolderChangedTrigger(templatesFactory.TemplatesFolderPath, "*.cshtml"); _folderChangedTrigger.Attach(templatesFactory); _folderChangedTrigger.Start(); } }
public MailNotifierBuilder FromConfig() { var config = EtherConfigSection.Instance; _fromAddress = config.FromAddress; _sendersPoolSize = config.PoolSize; string outgoingEmailsFolder = config.OutgoingEmailsFolder; if (string.IsNullOrEmpty(outgoingEmailsFolder)) { _outgoingQueue = new TransientQueue(); } else { _outgoingQueue = new PersistentQueue("OutgoingEmails", outgoingEmailsFolder); } Dictionary<string, MailingList> groups = config.MailingGroups .Cast<GroupConfigElement>() .ToDictionary(g => g.Name, g => MailingList.Parse(g.Participants)); _mailingListBroker = new MailingListBroker( config.MailingRules .Cast<MailingRuleConfigurationElement>() .Select( cfg => new MailingRule(cfg.Name, BuildMailingList(cfg.Recepients.SplitAndTrim(), groups))) .ToArray()); var templatesFactory = new RazorTemplatesFactory(config.TemplatesFolder); _templateEngine = new RazorMailTemplateEngine(templatesFactory, config.AutoReloadTemplates); _emailSenders = new IEmailSender[_sendersPoolSize]; for (int i = 0; i < _sendersPoolSize; i++) { _emailSenders[i] = new SmtpSender(); } return this; }
public void Setup() { var factory = new RazorTemplatesFactory(@"Resources"); _engine = new RazorMailTemplateEngine(factory, false); }