@@ -461,6 +461,7 @@ static void ParseESearchResults (ImapEngine engine, ImapCommand ic, SearchResult
461461 {
462462 var token = engine . ReadToken ( ic . CancellationToken ) ;
463463 UniqueId ? minValue = null , maxValue = null ;
464+ var folder = ic . Folder ! ;
464465 bool hasCount = false ;
465466 int parenDepth = 0 ;
466467 //bool uid = false;
@@ -558,18 +559,17 @@ static void ParseESearchResults (ImapEngine engine, ImapCommand ic, SearchResult
558559
559560 var min = ImapEngine . ParseNumber ( token , true , ImapEngine . GenericItemSyntaxErrorFormat , atom , token ) ;
560561
561- results . Min = new UniqueId ( ic . Folder ! . UidValidity , min ) ;
562+ results . Min = new UniqueId ( folder . UidValidity , min ) ;
562563 } else if ( atom . Equals ( "MAX" , StringComparison . OrdinalIgnoreCase ) ) {
563564 ImapEngine . AssertToken ( token , ImapTokenType . Atom , ImapEngine . GenericUntaggedResponseSyntaxErrorFormat , "ESEARCH" , token ) ;
564565
565566 var max = ImapEngine . ParseNumber ( token , true , ImapEngine . GenericItemSyntaxErrorFormat , atom , token ) ;
566567
567- results . Max = new UniqueId ( ic . Folder ! . UidValidity , max ) ;
568+ results . Max = new UniqueId ( folder . UidValidity , max ) ;
568569 } else if ( atom . Equals ( "ALL" , StringComparison . OrdinalIgnoreCase ) ) {
569570 ImapEngine . AssertToken ( token , ImapTokenType . Atom , ImapEngine . GenericUntaggedResponseSyntaxErrorFormat , "ESEARCH" , token ) ;
570571
571- var uids = ImapEngine . ParseUidSet ( token , ic . Folder ! . UidValidity , out minValue , out maxValue , ImapEngine . GenericItemSyntaxErrorFormat , atom , token ) ;
572-
572+ var uids = ImapEngine . ParseUidSet ( token , folder . UidValidity , out minValue , out maxValue , ImapEngine . GenericItemSyntaxErrorFormat , atom , token ) ;
573573 if ( ! hasCount )
574574 results . Count = uids . Count ;
575575
@@ -592,6 +592,7 @@ static async Task ParseESearchResultsAsync (ImapEngine engine, ImapCommand ic, S
592592 {
593593 var token = await engine . ReadTokenAsync ( ic . CancellationToken ) . ConfigureAwait ( false ) ;
594594 UniqueId ? minValue = null , maxValue = null ;
595+ var folder = ic . Folder ! ;
595596 bool hasCount = false ;
596597 int parenDepth = 0 ;
597598 //bool uid = false;
@@ -689,18 +690,17 @@ static async Task ParseESearchResultsAsync (ImapEngine engine, ImapCommand ic, S
689690
690691 var min = ImapEngine . ParseNumber ( token , true , ImapEngine . GenericItemSyntaxErrorFormat , atom , token ) ;
691692
692- results . Min = new UniqueId ( ic . Folder ! . UidValidity , min ) ;
693+ results . Min = new UniqueId ( folder . UidValidity , min ) ;
693694 } else if ( atom . Equals ( "MAX" , StringComparison . OrdinalIgnoreCase ) ) {
694695 ImapEngine . AssertToken ( token , ImapTokenType . Atom , ImapEngine . GenericUntaggedResponseSyntaxErrorFormat , "ESEARCH" , token ) ;
695696
696697 var max = ImapEngine . ParseNumber ( token , true , ImapEngine . GenericItemSyntaxErrorFormat , atom , token ) ;
697698
698- results . Max = new UniqueId ( ic . Folder ! . UidValidity , max ) ;
699+ results . Max = new UniqueId ( folder . UidValidity , max ) ;
699700 } else if ( atom . Equals ( "ALL" , StringComparison . OrdinalIgnoreCase ) ) {
700701 ImapEngine . AssertToken ( token , ImapTokenType . Atom , ImapEngine . GenericUntaggedResponseSyntaxErrorFormat , "ESEARCH" , token ) ;
701702
702- var uids = ImapEngine . ParseUidSet ( token , ic . Folder ! . UidValidity , out minValue , out maxValue , ImapEngine . GenericItemSyntaxErrorFormat , atom , token ) ;
703-
703+ var uids = ImapEngine . ParseUidSet ( token , folder . UidValidity , out minValue , out maxValue , ImapEngine . GenericItemSyntaxErrorFormat , atom , token ) ;
704704 if ( ! hasCount )
705705 results . Count = uids . Count ;
706706
@@ -733,6 +733,7 @@ static Task UntaggedESearchHandler (ImapEngine engine, ImapCommand ic, int index
733733
734734 static void ParseSearchResults ( ImapEngine engine , ImapCommand ic , SearchResults results )
735735 {
736+ var folder = ic . Folder ! ;
736737 var uids = results . UniqueIds ;
737738 uint min = uint . MaxValue ;
738739 uint uid , max = 0 ;
@@ -748,7 +749,7 @@ static void ParseSearchResults (ImapEngine engine, ImapCommand ic, SearchResults
748749 token = engine . ReadToken ( ic . CancellationToken ) ;
749750
750751 uid = ImapEngine . ParseNumber ( token , true , ImapEngine . GenericUntaggedResponseSyntaxErrorFormat , "SEARCH" , token ) ;
751- uids . Add ( new UniqueId ( ic . Folder ! . UidValidity , uid ) ) ;
752+ uids . Add ( new UniqueId ( folder . UidValidity , uid ) ) ;
752753 min = Math . Min ( min , uid ) ;
753754 max = Math . Max ( max , uid ) ;
754755 } while ( true ) ;
@@ -779,13 +780,14 @@ static void ParseSearchResults (ImapEngine engine, ImapCommand ic, SearchResults
779780 results . UniqueIds = uids ;
780781 results . Count = uids . Count ;
781782 if ( uids . Count > 0 ) {
782- results . Min = new UniqueId ( ic . Folder ! . UidValidity , min ) ;
783- results . Max = new UniqueId ( ic . Folder ! . UidValidity , max ) ;
783+ results . Min = new UniqueId ( folder . UidValidity , min ) ;
784+ results . Max = new UniqueId ( folder . UidValidity , max ) ;
784785 }
785786 }
786787
787788 static async Task ParseSearchResultsAsync ( ImapEngine engine , ImapCommand ic , SearchResults results )
788789 {
790+ var folder = ic . Folder ! ;
789791 var uids = results . UniqueIds ;
790792 uint min = uint . MaxValue ;
791793 uint uid , max = 0 ;
@@ -801,7 +803,7 @@ static async Task ParseSearchResultsAsync (ImapEngine engine, ImapCommand ic, Se
801803 token = await engine . ReadTokenAsync ( ic . CancellationToken ) . ConfigureAwait ( false ) ;
802804
803805 uid = ImapEngine . ParseNumber ( token , true , ImapEngine . GenericUntaggedResponseSyntaxErrorFormat , "SEARCH" , token ) ;
804- uids . Add ( new UniqueId ( ic . Folder ! . UidValidity , uid ) ) ;
806+ uids . Add ( new UniqueId ( folder . UidValidity , uid ) ) ;
805807 min = Math . Min ( min , uid ) ;
806808 max = Math . Max ( max , uid ) ;
807809 } while ( true ) ;
@@ -832,8 +834,8 @@ static async Task ParseSearchResultsAsync (ImapEngine engine, ImapCommand ic, Se
832834 results . UniqueIds = uids ;
833835 results . Count = uids . Count ;
834836 if ( uids . Count > 0 ) {
835- results . Min = new UniqueId ( ic . Folder ! . UidValidity , min ) ;
836- results . Max = new UniqueId ( ic . Folder ! . UidValidity , max ) ;
837+ results . Min = new UniqueId ( folder . UidValidity , min ) ;
838+ results . Max = new UniqueId ( folder . UidValidity , max ) ;
837839 }
838840 }
839841
0 commit comments