From 29e6599ae5ce654d997375d5e94a276b66db68d9 Mon Sep 17 00:00:00 2001 From: Daniel Collingwood <82693586+danzuep@users.noreply.github.com> Date: Mon, 23 Oct 2023 12:31:59 +0800 Subject: [PATCH] changed from switch expression to .NET standard2.0 compatible switch-case --- .../Services/ImapReceiver.cs | 2 +- .../Services/MailFolderClient.cs | 22 ++++++++++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/source/MailKitSimplified.Receiver/Services/ImapReceiver.cs b/source/MailKitSimplified.Receiver/Services/ImapReceiver.cs index ab0e3b7..78095e4 100644 --- a/source/MailKitSimplified.Receiver/Services/ImapReceiver.cs +++ b/source/MailKitSimplified.Receiver/Services/ImapReceiver.cs @@ -324,7 +324,7 @@ public async Task> GetMailFolderNamesAsync(CancellationToken cance public async Task MoveToSentAsync(IMessageSummary messageSummary, CancellationToken cancellationToken = default) { using (var mailFolderClient = _mailFolderClient.Value) - return await mailFolderClient.MoveOrCopyAsync(messageSummary.UniqueId, messageSummary.Folder, mailFolderClient.SentFolder.Value, move: true, cancellationToken).ConfigureAwait(false); + return await mailFolderClient.MoveOrCopyAsync(messageSummary.UniqueId, messageSummary.Folder, mailFolderClient.SentFolder, move: true, cancellationToken).ConfigureAwait(false); } public IImapReceiver Clone() diff --git a/source/MailKitSimplified.Receiver/Services/MailFolderClient.cs b/source/MailKitSimplified.Receiver/Services/MailFolderClient.cs index 140dcd5..aaebad4 100644 --- a/source/MailKitSimplified.Receiver/Services/MailFolderClient.cs +++ b/source/MailKitSimplified.Receiver/Services/MailFolderClient.cs @@ -181,14 +181,24 @@ public async Task DeleteMessagesAsync(TimeSpan relativeOffset, SearchQuery private IEnumerable GetFolderNames(SpecialFolder specialFolder) { - var folderNames = specialFolder switch + IList folderNames; + switch (specialFolder) { - SpecialFolder.Sent => SentFolderNames, - SpecialFolder.Drafts => DraftsFolderNames, - SpecialFolder.Junk => JunkFolderNames, - SpecialFolder.Trash => TrashFolderNames, + case SpecialFolder.Sent: + folderNames = SentFolderNames; + break; + case SpecialFolder.Drafts: + folderNames = DraftsFolderNames; + break; + case SpecialFolder.Junk: + folderNames = JunkFolderNames; + break; + case SpecialFolder.Trash: + folderNames = TrashFolderNames; + break; // All, Archive, Flagged, Important - _ => throw new NotImplementedException() + default: + throw new NotImplementedException(); }; return folderNames; }