wip starts migrating get remaining seconds, removes a bunch of code from netframework thats already been moved.
This commit is contained in:
@@ -6,6 +6,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
|
||||
{
|
||||
@@ -57,6 +58,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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user