Capitilize first letter of folder names if all capital for IMAP.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using MailKit;
|
||||
using Wino.Core.Domain.Entities;
|
||||
|
||||
@@ -8,14 +9,28 @@ namespace Wino.Core.Extensions
|
||||
{
|
||||
public static MailItemFolder GetLocalFolder(this IMailFolder mailkitMailFolder)
|
||||
{
|
||||
bool isAllCapital = mailkitMailFolder.Name?.All(a => char.IsUpper(a)) ?? false;
|
||||
|
||||
return new MailItemFolder()
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
FolderName = mailkitMailFolder.Name,
|
||||
FolderName = isAllCapital ? mailkitMailFolder.Name.OnlyCapitilizeFirstLetter() : mailkitMailFolder.Name,
|
||||
RemoteFolderId = mailkitMailFolder.FullName,
|
||||
ParentRemoteFolderId = mailkitMailFolder.ParentFolder?.FullName,
|
||||
SpecialFolderType = Domain.Enums.SpecialFolderType.Other
|
||||
};
|
||||
}
|
||||
|
||||
public static string OnlyCapitilizeFirstLetter(this string s)
|
||||
{
|
||||
if (string.IsNullOrEmpty(s))
|
||||
return string.Empty;
|
||||
|
||||
s = s.ToLower();
|
||||
|
||||
char[] a = s.ToCharArray();
|
||||
a[0] = char.ToUpper(a[0]);
|
||||
return new string(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user