Skip to content

Commit 9af11f4

Browse files
Add internal IsSupportedCommand extension method
1 parent d1b96c0 commit 9af11f4

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

src/ImageSharp.Web/Processors/WebProcessingExtensions.cs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ public static IEnumerable<IImageWebProcessor> GetBySupportedCommands(this IEnume
5959
foreach (IImageWebProcessor processor in processors)
6060
{
6161
// Get index of first supported command
62-
var processorCommands = new List<string>(processor.Commands);
63-
int index = commands.FindIndex(c => processorCommands.FindIndex(pc => pc.Equals(c, StringComparison.OrdinalIgnoreCase)) != -1);
62+
int index = commands.FindIndex(c => processor.IsSupportedCommand(c));
6463
if (index != -1)
6564
{
6665
indexedProcessors.Add((index, processor));
@@ -75,5 +74,26 @@ public static IEnumerable<IImageWebProcessor> GetBySupportedCommands(this IEnume
7574
yield return processor;
7675
}
7776
}
77+
78+
/// <summary>
79+
/// Determines whether the specified command is supported by the processor
80+
/// </summary>
81+
/// <param name="processor">The processor.</param>
82+
/// <param name="command">The command.</param>
83+
/// <returns>
84+
/// <c>true</c> if the specified command is supported by the processor; otherwise, <c>false</c>.
85+
/// </returns>
86+
public static bool IsSupportedCommand(this IImageWebProcessor processor, string command)
87+
{
88+
foreach (string processorCommand in processor.Commands)
89+
{
90+
if (processorCommand.Equals(command, StringComparison.OrdinalIgnoreCase))
91+
{
92+
return true;
93+
}
94+
}
95+
96+
return false;
97+
}
7898
}
7999
}

0 commit comments

Comments
 (0)