Antaris.AspNetCore.Mvc.Widgets.Infrastructure.DefaultWidgetSelector.WidgetDescriptorCache.Select C# (CSharp) Метод

Select() приватный статический Метод

private static Select ( WidgetDescriptor>.ILookup candidates, string name ) : WidgetDescriptor
candidates WidgetDescriptor>.ILookup
name string
Результат WidgetDescriptor
            private static WidgetDescriptor Select(ILookup<string, WidgetDescriptor> candidates, string name)
            {
                var matches = candidates[name];

                var count = matches.Count();
                if (count == 0)
                {
                    return null;
                }
                else if (count == 1)
                {
                    return matches.Single();
                }
                else
                {
                    var matchedTypes = new List<string>();
                    foreach (var candidate in matches)
                    {
                        matchedTypes.Add($"Type: {candidate.Type.FullName}, Name: {candidate.FullName}");
                    }

                    var typeNames = string.Join(Environment.NewLine, matchedTypes);
                    throw new InvalidOperationException($"The widget name matched multiple types:{Environment.NewLine}{typeNames}");
                }
            }
        }