diff --git a/ip2email/ip2email/Classes/AppConfig.cs b/ip2email/ip2email/Classes/AppConfig.cs index 78d9367..f76a11d 100644 --- a/ip2email/ip2email/Classes/AppConfig.cs +++ b/ip2email/ip2email/Classes/AppConfig.cs @@ -10,7 +10,7 @@ public class AppConfig { internal AppConfig() { - SetIsConfiguredState(); + isConfigured(EmailBody, EmailServer, EmailServerPort, RecipientEmail, SenderEmail, SenderPassword); } internal string EmailBody { get => DecodeFromRegistry("EBO"); set => EncodeToRegistry("EBO", value); } @@ -78,12 +78,18 @@ private void EncodeToRegistry(string regKeyName, string regKeyValue) } } - private void SetIsConfiguredState() + private void isConfigured(params string[] properties) { - IsConfigured = (SenderEmail == null || SenderPassword == null - || RecipientEmail == null - || EmailServer == null - || EmailServerPort == null) ? false : true; + foreach (var property in properties) + { + if (property is null) + { + IsConfigured = false; + break; + } + + IsConfigured = true; + } } } } \ No newline at end of file diff --git a/ip2email/ip2email/Helpers/TextHelper.cs b/ip2email/ip2email/Helpers/TextHelper.cs index e57181d..456fbf6 100644 --- a/ip2email/ip2email/Helpers/TextHelper.cs +++ b/ip2email/ip2email/Helpers/TextHelper.cs @@ -9,10 +9,10 @@ internal static class TextHelper internal static readonly string FailedGetInternetIP = "Failed to obtain public IP address"; internal static readonly string FailedGetLocalIP = "Failed to obtain local IP address"; internal static readonly string InternetIpSite = "https://ifconfig.me/ip"; - internal static readonly string RegistryAppName = "IP2Email"; - internal static readonly string RegistryAppPath = $@"{RegistryKeySoftware}\{RegistryKeyAuthor}\{RegistryAppName}"; + internal static readonly string RegistryAppName = "IP2Email"; internal static readonly string RegistryKeyAuthor = "Inestic"; internal static readonly string RegistryKeySoftware = "Software"; + internal static readonly string RegistryAppPath = $@"{RegistryKeySoftware}\{RegistryKeyAuthor}\{RegistryAppName}"; internal static readonly string SecurityKey = ""; internal static readonly string SenderDisplayName = "IP2Email"; }