????b??EmailService

namespace MonitorService
{
    public interface IEmailService
    {
        string To { get; set; }

        string Subject { get; set; }

        string Body { get; set; }

        /// <summary>
        /// ???????
        /// </summary>
        /// <param name="to"></param>
        /// <param name="subject"></param>
        /// <param name="body"></param>
        void SendEmail(string to?? string subject?? string body);
    }

    public class MockEmailService : IEmailService
    {
        public string To { get; set; }

        public string Subject { get; set; }

        public string Body { get; set; }

        public void SendEmail(string to?? string subject?? string body)
        {
            To = to;
            Subject = subject;
            Body = body;
        }
    }
}

???????????????????Analyze????????????????????????????

????c??ConfigFileMonitor

using System;
using MonitorService.Contract;

namespace MonitorService.Impl
{
    /// <summary>
    /// ???????????????
    /// </summary>
    public class ConfigFileMonitor : IFileMonitor
    {
        public ILogService LogService { get; set; }

        public IEmailService EmailService { get; set; }

        private static readonly string configFileType = ".config";//??????????

        public void Analyze(string fileName)
        {
            try
            {
                if (fileName.Length <= configFileType.Length)
                {
                    LogService.AppendLog(string.Format("input filename({0}) is too short"?? fileName));
                }
            }
            catch (Exception ex)
            {
                EmailService.SendEmail("mailto:jeffwong@cnblogs.com jeffwong@cnblogs.com"?? "filename check"?? ex.Message);
            }
        }
    }
}