From cad5239f816bc3f116a6ad8d3dea9e1e3f831a65 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 10 Sep 2022 17:38:57 -0500 Subject: simplify enum handling --- src/slskd/Integrations/FTP/FTPClientFactory.cs | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) (limited to 'src/slskd/Integrations/FTP/FTPClientFactory.cs') diff --git a/src/slskd/Integrations/FTP/FTPClientFactory.cs b/src/slskd/Integrations/FTP/FTPClientFactory.cs index 2e41ab03..70cfbc03 100644 --- a/src/slskd/Integrations/FTP/FTPClientFactory.cs +++ b/src/slskd/Integrations/FTP/FTPClientFactory.cs @@ -47,24 +47,10 @@ namespace slskd.Integrations.FTP public FtpClient CreateFtpClient() { var client = new FtpClient(FtpOptions.Address, FtpOptions.Port, FtpOptions.Username, FtpOptions.Password); - client.EncryptionMode = ParseFtpEncryptionMode(FtpOptions.EncryptionMode); + client.EncryptionMode = FtpOptions.EncryptionMode.ToEnum(); client.ValidateAnyCertificate = FtpOptions.IgnoreCertificateErrors; return client; } - - private FtpEncryptionMode ParseFtpEncryptionMode(string encryptionMode) - { - try - { - return (FtpEncryptionMode)Enum.Parse(typeof(FtpEncryptionMode), encryptionMode, ignoreCase: true); - } - catch (Exception ex) - { - // Options should validate that the given string is parsable to FtpEncryptionMode through EnumAttribute; if this - // throws there's a bug somewhere. - throw new ArgumentException($"Failed to parse {typeof(FtpEncryptionMode).Name} from application Options. This is most likely a programming error; please file a GitHub issue and include your FTP configuration.", ex); - } - } } } \ No newline at end of file -- cgit v1.2.3