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);
}