示例#1
0
 internal SmtpAgent(SmtpAgentSettings settings)
 {
     if (settings == null)
     {
         throw new ArgumentNullException("settings");
     }
     
     this.Init(settings);
 }
 static void EnsureDefaults(SimpleDependencyResolver dependencyResolver, SmtpAgentSettings settings)
 {
     if (!dependencyResolver.IsRegistered<ILogFactory>())
     {
         dependencyResolver.Register<ILogFactory>(new NLogFactory(settings.LogSettings));
     }
     if (!dependencyResolver.IsRegistered<IAuditor>())
     {
         dependencyResolver.Register<IAuditor>(new EventLogAuditor());
     }
 }
        static void LogError(SmtpAgentSettings settings, Exception ex)
        {
            // if we blow up here we should write out to the EventLog w/o any logger
            // dependencies, etc...
            string source = settings == null
                            || settings.LogSettings == null
                            || string.IsNullOrEmpty(settings.LogSettings.EventLogSource)
                                ? null
                                : settings.LogSettings.EventLogSource;

            EventLogHelper.WriteError(source, "While loading SmtpAgent settings - " + ex);
        }
 private static void InitializeContainer(SmtpAgentSettings settings)
 {
     lock (m_initSync)
     {
         if (!m_initialized)
         {
             SimpleDependencyResolver dependencyResolver = new SimpleDependencyResolver();
             if (settings.HasContainer && settings.Container.HasComponents)
             {
                 try
                 {
                     dependencyResolver.Register(settings.Container);
                 }
                 catch(Exception ex)
                 {
                     LogError(settings, ex);
                 }
             }
             EnsureDefaults(dependencyResolver, settings);
             IoC.Initialize(dependencyResolver);
             m_initialized = true;
         }
     }
 }
 internal MonitorService(SmtpAgentSettings settings)
 {
     m_settings = settings;
 }
示例#6
0
 internal ConfigService(SmtpAgentSettings settings)
 {
     m_settings = settings;
 }
示例#7
0
        //---------------------------------------------------
        //
        //  Agent Initialization
        //
        //---------------------------------------------------
        void Init(SmtpAgentSettings settings)
        {
            m_settings = settings;
            m_settings.Validate();

            m_auditor = IoC.Resolve<IAuditor>();
            m_logger = Log.For(this);

            m_diagnostics = new AgentDiagnostics(this);
            m_configService = new ConfigService(m_settings);
            m_monitorService = new MonitorService(m_settings);

            using (new MethodTracer(Logger))
            {
                try
                {
                    //
                    // First, setup defaults using Xml Config
                    //
                    this.InitDomains();
                    this.InitFolders();
                    this.InitRoutes();
                    this.InitNotifications();
                    //
                    // Call config service, if any was configured
                    //
                    this.InitDomainsFromConfigService();
                    //
                    // Finally, we can agent...
                    //
                    this.InitAgent();
                    this.SubscribeToAgentEvents();
                    this.ConfigureServicePoints();
                }
                catch (Exception ex)
                {
                    Logger.Error("While initializing {0}", ex.ToString());
                    throw;
                }
            }
        }
示例#8
0
 internal ConfigService(SmtpAgentSettings settings)
 {
     m_settings = settings;
 }
示例#9
0
 internal MonitorService(SmtpAgentSettings settings)
 {
     m_settings = settings;
 }