Merge remote-tracking branch 'origin/netcore/netcore' into netcore/feature/migrate-remaining-trees

This commit is contained in:
Bjarke Berg
2020-06-11 15:21:51 +02:00
59 changed files with 841 additions and 668 deletions

View File

@@ -7,6 +7,7 @@ using Umbraco.Web.Common.Install;
using Umbraco.Core.Hosting;
using System.Linq.Expressions;
using Umbraco.Web.Common.Controllers;
using System.Linq;
namespace Umbraco.Extensions
{
@@ -58,6 +59,23 @@ namespace Umbraco.Extensions
return linkGenerator.GetUmbracoApiService(actionName, typeof(T), id);
}
public static string GetUmbracoApiService<T>(this LinkGenerator url, Expression<Func<T, object>> methodSelector)
where T : UmbracoApiControllerBase
{
var method = ExpressionHelper.GetMethodInfo(methodSelector);
var methodParams = ExpressionHelper.GetMethodParams(methodSelector);
if (method == null)
{
throw new MissingMethodException("Could not find the method " + methodSelector + " on type " + typeof(T) + " or the result ");
}
if (methodParams.Any() == false)
{
return url.GetUmbracoApiService<T>(method.Name);
}
return url.GetUmbracoApiService<T>(method.Name, methodParams.Values.First());
}
public static string GetUmbracoApiServiceBaseUrl<T>(this LinkGenerator linkGenerator, Expression<Func<T, object>> methodSelector)
where T : UmbracoApiControllerBase
{