private static IWidgetResult CoerceToWidgetResult(object value)
{
var widgetResult = value as IWidgetResult;
if (widgetResult != null)
{
return widgetResult;
}
var stringResult = value as string;
if (stringResult != null)
{
return new ContentWidgetResult(stringResult);
}
var htmlStringResult = value as HtmlString;
if (htmlStringResult != null)
{
return new ContentWidgetResult(htmlStringResult);
}
throw new InvalidOperationException($"Widgets only support returning {typeof(string).Name}, {typeof(HtmlString).Name} or {typeof(IWidgetResult).Name}");
}