public void Update(ISmtpServerOptions smtpServerOptions)
 {
     AddOrUpdate(new SystemSettingDto
     {
         Name  = SmtpServer,
         Value = smtpServerOptions.SmtpServer
     });
     AddOrUpdate(new SystemSettingDto
     {
         Name  = SmtpServerPort,
         Value = smtpServerOptions.SmtpServerPort.ToString()
     });
     AddOrUpdate(new SystemSettingDto
     {
         Name  = SmtpSslEncryption,
         Value = smtpServerOptions.SmtpServerUseSSl.ToString()
     });
     AddOrUpdate(new SystemSettingDto
     {
         Name  = SmtpAuthentication,
         Value = smtpServerOptions.SmtpAuthentication.ToString()
     });
     AddOrUpdate(new SystemSettingDto
     {
         Name  = SmtpServerUsername,
         Value = productionCipher.Encrypt(smtpServerOptions.SmtpServerUser, encryptorKey)
     });
     AddOrUpdate(new SystemSettingDto
     {
         Name  = SmtpServerPassword,
         Value = productionCipher.Encrypt(smtpServerOptions.SmtpServerPassword, encryptorKey)
     });
 }
Exemplo n.º 2
0
        private object SetSpecificValue(PropertyInfo fromProperty, PropertyInfo toProperty, object fromValue)
        {
            if (fromProperty.PropertyType == typeof(DateTime))
            {
                return(AutoConvertDateTime(fromProperty, toProperty, (DateTime)fromValue));
            }
            if (fromProperty.PropertyType == typeof(DateTime?))
            {
                var nullableDate = (DateTime?)fromValue;
                if (nullableDate.HasValue)
                {
                    return(AutoConvertDateTime(fromProperty, toProperty, nullableDate.Value));
                }
            }
            var encryptionKey = GetEncryptionKey(fromProperty.GetEncryptionAttribute());

            if (encryptionKey != null)
            {
                return(productionCipher.Decrypt(fromValue.ToString(), encryptionKey));
            }
            encryptionKey = GetEncryptionKey(toProperty.GetEncryptionAttribute());
            if (encryptionKey != null)
            {
                return(productionCipher.Encrypt(fromValue.ToString(), encryptionKey));
            }

            return(fromValue);
        }