/// <summary>
 /// Performs the default action between Queue and Send
 /// </summary>
 /// <param name="message">The message to queue or send</param>
 public static void TryQueueOrSend <T>(IQueueAndSendMail sender, T message) where T : IEmailMessage
 {
     if (sender != null)
     {
         sender.QueueOrSend(message);
     }
 }
 /// <summary>
 /// Copies the provided message and requeues it with an optional new recipient, marks it sent, and then immediately sends it
 /// </summary>
 /// <param name="message">The message to copy</param>
 /// <param name="newRecipient">If not null, the value will replace the former recipient</param>
 public static void TryReQueueAndSend <T>(IQueueAndSendMail sender, T message, string newRecipient = null) where T : IEmailMessage
 {
     if (sender != null)
     {
         sender.ReQueueAndSend(message, newRecipient);
     }
 }
 /// <summary>
 /// Sends the email immediately and inserts it into a database in the "Sent" state for record
 /// </summary>
 /// <param name="message">The message to send and queue</param>
 public static void TryQueueAndSend(IQueueAndSendMail sender, IEmailMessage message)
 {
     if (sender != null)
     {
         sender.QueueAndSend(message);
     }
 }
 /// <summary>
 /// Creates a new instance of this repository
 /// </summary>
 /// <param name="dbContext">The persistance context to be used when accessing templates</param>
 /// <param name="emailRepository">An IRepository information used to persist generated email messages</param>
 /// <param name="emailRenderer">An IEmailRenderer implementation used to bind the template as well as output HTML</param>
 /// <param name="messageBus">An optional message bus for sending EmailTemplate messages</param>
 public EmailTemplateRepository(IPersistenceContext <EmailTemplate> dbContext, IQueueAndSendMail emailRepository, IEmailTemplateRenderer emailRenderer, MessageBus messageBus = null) : base(dbContext, messageBus)
 {
     this.EmailRenderer   = emailRenderer;
     this.EmailRepository = emailRepository;
 }