2024-06-14 19:06:21 -04:00
|
|
|
|
using ReCodeIt.Enums;
|
2024-06-13 07:45:40 -04:00
|
|
|
|
using MoreLinq.Extensions;
|
2024-06-13 04:56:08 -04:00
|
|
|
|
|
2024-06-14 19:06:21 -04:00
|
|
|
|
namespace ReCodeIt.Utils;
|
2024-06-13 04:56:08 -04:00
|
|
|
|
|
|
|
|
|
internal static class EnumExtensions
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns a match from a list of match results
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="matches"></param>
|
|
|
|
|
/// <returns>highest EMatchResult</returns>
|
|
|
|
|
public static EMatchResult GetMatch(this List<EMatchResult> matches)
|
|
|
|
|
{
|
2024-06-13 07:45:40 -04:00
|
|
|
|
// Prioritize returning matches
|
|
|
|
|
if (matches.Contains(EMatchResult.Match)) { return EMatchResult.Match; }
|
2024-06-13 04:56:08 -04:00
|
|
|
|
|
2024-06-13 07:45:40 -04:00
|
|
|
|
// Then NoMatches
|
2024-06-13 04:56:08 -04:00
|
|
|
|
if (matches.Contains(EMatchResult.NoMatch)) { return EMatchResult.NoMatch; }
|
|
|
|
|
|
2024-06-13 07:45:40 -04:00
|
|
|
|
// Then Disabled
|
|
|
|
|
if (matches.Contains(EMatchResult.Disabled)) { return EMatchResult.Disabled; }
|
2024-06-13 04:56:08 -04:00
|
|
|
|
|
|
|
|
|
// default to disabled
|
|
|
|
|
return EMatchResult.Disabled;
|
|
|
|
|
}
|
|
|
|
|
}
|