File tree Expand file tree Collapse file tree 1 file changed +28
-5
lines changed
src/ImageSharp.Web/Processors Expand file tree Collapse file tree 1 file changed +28
-5
lines changed Original file line number Diff line number Diff line change @@ -54,10 +54,33 @@ public static FormattedImage Process(
5454 /// The sorted proccessors that supports any of the specified commands.
5555 /// </returns>
5656 public static IEnumerable < IImageWebProcessor > GetBySupportedCommands ( this IEnumerable < IImageWebProcessor > processors , List < string > commands )
57- => processors
58- . GroupBy ( p => commands . FindIndex ( c => p . Commands . Contains ( c , StringComparer . OrdinalIgnoreCase ) ) ) // Get index of first supported command
59- . Where ( g => g . Key != - 1 ) // Filter processors without supported commands
60- . OrderBy ( g => g . Key ) // Order processors by first supported command
61- . SelectMany ( g => g ) ;
57+ {
58+ var sortedProcessors = new SortedDictionary < int , IList < IImageWebProcessor > > ( ) ;
59+
60+ foreach ( IImageWebProcessor processor in processors )
61+ {
62+ // Get index of first supported command
63+ int index = commands . FindIndex ( c => processor . Commands . Contains ( c , StringComparer . OrdinalIgnoreCase ) ) ;
64+ if ( index != - 1 )
65+ {
66+ if ( ! sortedProcessors . TryGetValue ( index , out IList < IImageWebProcessor > indexProcessors ) )
67+ {
68+ indexProcessors = new List < IImageWebProcessor > ( ) ;
69+ sortedProcessors . Add ( index , indexProcessors ) ;
70+ }
71+
72+ indexProcessors . Add ( processor ) ;
73+ }
74+ }
75+
76+ // Return sorted processors
77+ foreach ( IEnumerable < IImageWebProcessor > values in sortedProcessors . Values )
78+ {
79+ foreach ( IImageWebProcessor value in values )
80+ {
81+ yield return value ;
82+ }
83+ }
84+ }
6285 }
6386}
You can’t perform that action at this time.
0 commit comments