<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Codestellation.Mailer.Core;
using Codestellation.Mailer.Mailing;
using Codestellation.Mailer.Templating;
using Codestellation.Mailer.Transport;

namespace Codestellation.Mailer
{
    public class MailNotifier : IMailNotifier
    {
        private readonly string _fromAddress;
        private readonly ISmtpClient _smtpClient;
        private readonly IMailingListBroker _mailingListBroker;
        private readonly IMailTemplateEngine _templateEngine;


        public MailNotifier(string fromAddress, ISmtpClient smtpClient, IMailingListBroker mailingListBroker, IMailTemplateEngine templateEngine)
        {
            _fromAddress = fromAddress;
            _smtpClient = smtpClient;
            _mailingListBroker = mailingListBroker;
            _templateEngine = templateEngine;
        }

        public void Send(object mail)
        {
            Type mailType = mail.GetType();
            MailView view = _templateEngine.Render(mail);
            var email = new Email(_fromAddress,
                                  _mailingListBroker.GetRecepients(mailType).ToArray(),
                                  view);
                

            _smtpClient.Send(email);
        }
    }
}<commit_msg>Adding configuration validation (closed #5)<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Codestellation.Mailer.Core;
using Codestellation.Mailer.Mailing;
using Codestellation.Mailer.Templating;
using Codestellation.Mailer.Transport;

namespace Codestellation.Mailer
{
    public class MailNotifier : IMailNotifier
    {
        private readonly string _fromAddress;
        private readonly ISmtpClient _smtpClient;
        private readonly IMailingListBroker _mailingListBroker;
        private readonly IMailTemplateEngine _templateEngine;


        public MailNotifier(string fromAddress, ISmtpClient smtpClient, IMailingListBroker mailingListBroker, IMailTemplateEngine templateEngine)
        {
            if(string.IsNullOrEmpty(fromAddress))
            {
                throw new ArgumentNullException("fromAddress");
            }
            _fromAddress = fromAddress;
            _smtpClient = smtpClient;
            _mailingListBroker = mailingListBroker;
            _templateEngine = templateEngine;
        }

        public void Send(object mail)
        {
            Type mailType = mail.GetType();
            MailView view = _templateEngine.Render(mail);
            var email = new Email(_fromAddress,
                                  _mailingListBroker.GetRecepients(mailType).ToArray(),
                                  view);
                

            _smtpClient.Send(email);
        }
    }
}
{'fraction_non_alphanumeric': 0.0616535994297933, 'fraction_numerical': 0.0003563791874554526, 'mean_word_length': 2.3819277108433736, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3061793', 'n_tokens_mistral': 752, 'n_tokens_neox': 708, 'n_words': 152}