26 lines
890 B
C#
26 lines
890 B
C#
namespace WxAgent.Core;
|
|
|
|
public static class WechatMentionOptionSelection
|
|
{
|
|
public static int FindUniqueVisibleOptionIndex(
|
|
IReadOnlyList<string?> groupMemberDisplayNames,
|
|
IReadOnlyList<(string? Name, bool IsOffscreen, bool HasBounds)> options,
|
|
string requestedName)
|
|
{
|
|
ArgumentException.ThrowIfNullOrWhiteSpace(requestedName);
|
|
if (groupMemberDisplayNames.Count(name => string.Equals(name, requestedName, StringComparison.Ordinal)) != 1)
|
|
return -1;
|
|
|
|
var match = -1;
|
|
for (var index = 0; index < options.Count; index++)
|
|
{
|
|
var option = options[index];
|
|
if (!string.Equals(option.Name, requestedName, StringComparison.Ordinal)) continue;
|
|
if (match >= 0 || option.IsOffscreen || !option.HasBounds) return -1;
|
|
match = index;
|
|
}
|
|
|
|
return match;
|
|
}
|
|
}
|