internal new ImapCommandResult Prepare(ImapFetchDataItem fetchDataItemMacro, out IImapMessageAttribute messageAttr) { var result = base.Prepare(fetchDataItemMacro, out messageAttr); if (result.Failed) // not to close session by this instance DetachFromSession(); return result; }
private ImapWebResponse GetSortResponse() { if (SortCriteria == null) throw new InvalidOperationException("SortCriteria must be set"); string charset; ImapMatchedSequenceSet matched; var result = Session.UidSortPreformatted(SortCriteria, GetSearchCriteria(Session.ServerCapabilities, out charset), charset, out matched); if (result.Failed) return CreateSearchErrorResponse(result); else if (matched.IsEmpty) return CreateNotMatchedResponse(result); ImapMessageAttribute[] messageAttributes; var response = new ImapWebResponse(Session.Fetch(matched, GetFetchDataItem(), out messageAttributes)); if (response.Result.Failed) return response; var sortedUids = matched.ToArray(); var sortedMessageAttributes = new IImapMessageAttribute[sortedUids.Length]; for (var i = 0; i < sortedUids.Length; i++) { sortedMessageAttributes[i] = null; for (var j = 0; j < messageAttributes.Length; j++) { if (sortedUids[i] == messageAttributes[j].Uid) { sortedMessageAttributes[i] = messageAttributes[j]; break; } } } response.MessageAttributes = sortedMessageAttributes; return response; }