Antaris.AspNetCore.Mvc.Widgets.Internal.WidgetMethodSelector.FindAsyncMethod C# (CSharp) Метод

FindAsyncMethod() публичный статический Метод

Finds an asynchronous method to execute.
public static FindAsyncMethod ( WidgetContext context, TypeInfo widgetType ) : MethodInfo
context Antaris.AspNetCore.Mvc.Widgets.Infrastructure.WidgetContext The widget context.
widgetType System.Reflection.TypeInfo The widget type.
Результат System.Reflection.MethodInfo
        public static MethodInfo FindAsyncMethod(WidgetContext context, TypeInfo widgetType)
        {
            string httpMethod = ResolveHttpMethod(context);
            string state = string.Empty; // Resolve a widget state?
            MethodInfo method = null;

            for (int i = 0; i < AsyncMethodNames.Length; i++)
            {
                string name = string.Format(AsyncMethodNames[i], state, httpMethod);
                method = GetMethod(name, widgetType);
                if (method != null)
                {
                    break;
                }
            }

            if (method == null)
            {
                return null;
            }

            if (!method.ReturnType.GetTypeInfo().IsGenericType
                || method.ReturnType.GetGenericTypeDefinition() != typeof(Task<>))
            {
                throw new InvalidOperationException($"Async method '{method.Name}' must return a task.");
            }

            return method;
        }