Esempio n. 1
0
        private ObjectWHeaders GetView(string contentTypeCategory, string contentTypeSpecific)
        {
            // Full match
            string contentType = contentTypeCategory + "/" + contentTypeSpecific;

            if (ContentType.Equals(contentType, StringComparison.OrdinalIgnoreCase) ||
                ContentType.StartsWith(contentType + ";", StringComparison.OrdinalIgnoreCase))
            {
                return(this);
            }

            ObjectWHeaders match = AlternateViews.Where(view =>
                                                        view.ContentType.Equals(contentType, StringComparison.OrdinalIgnoreCase) ||
                                                        ContentType.StartsWith(contentType + ";", StringComparison.OrdinalIgnoreCase)).FirstOrDefault();

            if (match != null)
            {
                return(match);
            }

            // partial match
            if (ContentType.StartsWith(contentTypeCategory + "/", StringComparison.OrdinalIgnoreCase))
            {
                return(this);
            }
            return(AlternateViews.Where(view =>
                                        view.ContentType.StartsWith(contentTypeCategory + "/", StringComparison.OrdinalIgnoreCase)).FirstOrDefault());
        }
Esempio n. 2
0
 public virtual async Task LazyLoadBodyPartAsync(MailMessage message, ObjectWHeaders part)
 {
     if (part.Scope < Scope.HeadersAndBody)
     {
         if (MailStorage.HasMessagePart(message.GetThreadId(), message.GetMessageId(), part.BodyId))
         {
             part.Body = await MailStorage.GetMessagePartAsync(message.GetThreadId(), message.GetMessageId(), part.BodyId);
         }
         else
         {
             await GmailImap.GetBodyPartAsync(message.Uid, part, async () =>
             {
                 if (ActiveLabel.Info.StoreMessages)
                 {
                     await MailStorage.StoreMessagePartAsync(message.GetThreadId(), message.GetMessageId(), part.BodyId, part.Body);
                 }
             }, CancellationToken.None);
         }
     }
 }