private static void ReadOptionsFromConfig()
        {
            // Make sure we have options to change
            if (_options == null)
            {
                _options = new WorkerOptions();
            }

            // Try to read the RunImmediately value from app.config
            string configRunImmediately = ConfigurationManager.AppSettings["RunImmediately"];
            bool   runImmediately;

            if (Boolean.TryParse(configRunImmediately, out runImmediately))
            {
                _options.RunImmediately = runImmediately;
            }

            // Try to read the Email value from app.config
            string configEmail = ConfigurationManager.AppSettings["Email"];

            if (!String.IsNullOrEmpty(configEmail))
            {
                _options.Email = configEmail;
            }

            // Try to read the email username value from app.config
            string configEmailUsername = ConfigurationManager.AppSettings["MAILGUN_SMTP_LOGIN"];

            if (!String.IsNullOrEmpty(configEmailUsername))
            {
                _options.EmailUsername = configEmailUsername;
            }

            // Try to read the email password value from app.config
            string configEmailPassword = ConfigurationManager.AppSettings["MAILGUN_SMTP_PASSWORD"];

            if (!String.IsNullOrEmpty(configEmailPassword))
            {
                _options.EmailPassword = configEmailPassword;
            }

            // Try to read the email password value from app.config
            string configEmailServer = ConfigurationManager.AppSettings["MAILGUN_SMTP_SERVER"];

            if (!String.IsNullOrEmpty(configEmailServer))
            {
                _options.EmailServer = configEmailServer;
            }

            // Try to read the email password value from app.config
            string configEmailPort = ConfigurationManager.AppSettings["MAILGUN_SMTP_PORT"];
            int    emailPort;

            if (!String.IsNullOrEmpty(configEmailServer) && Int32.TryParse(configEmailPort, out emailPort))
            {
                _options.EmailPort = emailPort;
            }
        }
Example #2
0
        private static void ReadOptionsFromConfig() {

            // Make sure we have options to change
            if (_options == null)
                _options = new WorkerOptions();

            // Try to read the RunImmediately value from app.config
            string configRunImmediately = ConfigurationManager.AppSettings["RunImmediately"];
            bool runImmediately;

            if (Boolean.TryParse(configRunImmediately, out runImmediately)) {
                _options.RunImmediately = runImmediately;
            }

            // Try to read the Email value from app.config
            string configEmail = ConfigurationManager.AppSettings["Email"];

            if (!String.IsNullOrEmpty(configEmail)) {
                _options.Email = configEmail;
            }

            // Try to read the email username value from app.config
            string configEmailUsername = ConfigurationManager.AppSettings["MAILGUN_SMTP_LOGIN"];

            if (!String.IsNullOrEmpty(configEmailUsername)) {
                _options.EmailUsername = configEmailUsername;
            }

            // Try to read the email password value from app.config
            string configEmailPassword = ConfigurationManager.AppSettings["MAILGUN_SMTP_PASSWORD"];

            if (!String.IsNullOrEmpty(configEmailPassword)) {
                _options.EmailPassword = configEmailPassword;
            }

            // Try to read the email password value from app.config
            string configEmailServer = ConfigurationManager.AppSettings["MAILGUN_SMTP_SERVER"];

            if (!String.IsNullOrEmpty(configEmailServer)) {
                _options.EmailServer = configEmailServer;
            }

            // Try to read the email password value from app.config
            string configEmailPort = ConfigurationManager.AppSettings["MAILGUN_SMTP_PORT"];
            int emailPort;

            if (!String.IsNullOrEmpty(configEmailServer) && Int32.TryParse(configEmailPort, out emailPort)) {
                _options.EmailPort = emailPort;
            }
        }