Antaris.AspNetCore.Mvc.Widgets.Infrastructure.DefaultWidgetInvoker.InvokeAsync C# (CSharp) Method

InvokeAsync() public method

public InvokeAsync ( WidgetContext context ) : System.Threading.Tasks.Task
context WidgetContext
return System.Threading.Tasks.Task
        public async Task InvokeAsync(WidgetContext context)
        {
            IWidgetResult result;
            var asyncMethod = WidgetMethodSelector.FindAsyncMethod(context, context.WidgetDescriptor.Type.GetTypeInfo());

            if (asyncMethod == null)
            {
                var syncMethod = WidgetMethodSelector.FindSyncMethod(context, context.WidgetDescriptor.Type.GetTypeInfo());

                if (syncMethod == null)
                {
                    throw new InvalidOperationException("Cannot find an appropriate method.");
                }

                result = InvokeSyncCore(syncMethod, context);
            }
            else
            {
                result = await InvokeAsyncCore(asyncMethod, context);
            }

            await result.ExecuteAsync(context);
        }