private static void InitInternal()
        {
            try
            {
                if (_validationResult == null)
                {
                    _validationResult = new List <ValidationResult>();
                }

                var section = ConfigurationSectionBase.GetSection <ExceptionNotificationSettingsSection>("exceptionNotificationSettingsSection");

                if (section == null)
                {
                    return;
                }

                _emailMessage = new EmailMessage();

                _settings = new Dictionary <string, ExceptionNotificationSettings>();


                var types = ReflectionHelper.GetAllTypes(t => typeof(Exception).IsAssignableFrom(t))
                            .Distinct(new TypeComparer());

                PopulateEmaiMessage(section.EmailConfiguration);

                var timer = new Stopwatch();

                //ToDo: review
                //LoggerManager.WriteInformationToEventLog("Loading all exceptions...");

                timer.Start();

                var dict = types.ToDictionary(k => k.FullName);

                timer.Stop();
                //ToDo: review
                //LoggerManager.WriteInformationToEventLog(string.Format("Loading all exceptions took {0}", timer.Elapsed));


                foreach (ExceptionNotificationSettingsConfigurationElement setting in section.ExceptionNotificationSettings)
                {
                    if (!dict.ContainsKey(setting.Name) || _settings.ContainsKey(setting.Name))
                    {
                        continue;
                    }

                    double minutes;

                    if (!ReflectionHelper.TryParseOrDefault <double>(setting.TimeSpan, out minutes))
                    {
                        _validationResult.Add(new ValidationResult(string.Format("Configuration setting TimeSpan for {0} is not numerical. Value is {1}.", setting.Name, setting.TimeSpan)));
                        //ToDo: review
                        //LoggerManager.WriteWarningToEventLog(string.Format("Configuration setting TimeSpan for {0} is not numerical. Value is {1}.", setting.Name, setting.TimeSpan));

                        continue;
                    }

                    var newSettings = new ExceptionNotificationSettings
                    {
                        NotificationEntryType = dict[setting.Name],
                        TimeSpan = TimeSpan.FromMinutes(minutes),
                        To       = setting.OverrideRecipients.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                    };

                    if (!IsSettingsValid(newSettings, _validationResult))
                    {
                        continue;
                    }

                    _settings[setting.Name] = newSettings;
                }
            }
            catch (Exception ex)
            {
                _error = ex;
                //ToDo: review
                //LoggerManager.WriteExceptionToEventLog(ex);
            }
            finally
            {
                _isValid = _error == null && _validationResult.Count == 0;
            }
        }
        private static void InternalInit()
        {
            try
            {
                if (_validationResult == null)
                {
                    _validationResult = new List <ValidationResult>();
                }

                var section = ConfigurationSectionBase.GetSection <SmptProviderSettingsSection>("smptProviderSettingsSection");

                var settings = section.SmptSettings;

                if (settings.Contains("Path"))
                {
                    var settingValue = settings["Path"].Value;

                    if (string.IsNullOrWhiteSpace(settingValue))
                    {
                        LoggerManager.WriteWarningToEventLog("Path cannot be empty");

                        _validationResult.Add(new ValidationResult("Path cannot be empty"));
                    }
                    else
                    {
                        _path = settingValue;
                    }
                }
                else
                {
                    _validationResult.Add(new ValidationResult("Path does not exist in configuration section"));
                }

                if (settings.Contains("Port"))
                {
                    var settingValue = settings["Port"].Value;

                    int portNumeric;

                    if (!ReflectionHelper.TryParseOrDefault <int>(settingValue, out portNumeric))
                    {
                        _validationResult.Add(new ValidationResult(string.Format("Port setting is not numerical. Value is {0}", settingValue)));

                        LoggerManager.WriteWarningToEventLog(string.Format("Port setting is not numerical. Value is {0}", settingValue));
                    }
                    else
                    {
                        _port = portNumeric;
                    }
                }

                if (settings.Contains("IsSSLEnabled"))
                {
                    var settingValue = settings["IsSSLEnabled"].Value;

                    if (!ReflectionHelper.TryParseOrDefault <bool>(settingValue, out _isSSLEnabled))
                    {
                        _validationResult.Add(new ValidationResult(string.Format("Port setting is not numerical. Value is {0}", settingValue)));

                        LoggerManager.WriteWarningToEventLog(string.Format("Port setting is not numerical. Value is {0}", settingValue));
                    }
                }

                if (settings.Contains("UserName"))
                {
                    var settingValue = settings["UserName"].Value;

                    if (string.IsNullOrWhiteSpace(settingValue))
                    {
                        LoggerManager.WriteWarningToEventLog("UserName cannot be empty");

                        _validationResult.Add(new ValidationResult("UserName cannot be empty"));
                    }
                    else
                    if (!EmailValidator.ValidateEmail(settingValue))
                    {
                        LoggerManager.WriteWarningToEventLog(string.Format("UserName is not a valid e-mail format. Value is {0}", settingValue));

                        _validationResult.Add(new ValidationResult(string.Format("UserName is not a valid e-mail format. Value is {0}", settingValue)));
                    }
                    else
                    {
                        _userName = settingValue;
                    }
                }
                else
                {
                    _validationResult.Add(new ValidationResult("UserName does not exist in configuration section"));
                }
#if DEBUG
                _password = StringExtensions.ToSecureString("Password1");
#else
                if (settings.Contains("Password"))
                {
                    var encryptedPassword = settings["Password"].Value;

                    var secureString = Kernel.Cryptography.DPAPIEncryption.DecryptString(encryptedPassword);

                    _password = secureString;
                }
                else
                {
                    _validationResult.Add(new ValidationResult("Password does not exist in configuration section"));
                }
#endif
            }
            catch (Exception ex)
            {
                _error = ex;

                LoggerManager.WriteExceptionToEventLog(ex);
            }
            finally
            {
                _isValid = _error == null && _validationResult.Count == 0;
            }
        }