public static void Redirect(this IXAFAppWebAPI api, string url, bool endResponse = true) { if (api.Application.GetPlatform() == Platform.Blazor) { api.GetService("Microsoft.AspNetCore.Components.NavigationManager").CallMethod("NavigateTo", url, endResponse); } else { AppDomain.CurrentDomain.XAF().WebApplicationType() .GetMethod("Redirect", new[] { typeof(string), typeof(bool) }) ?.Invoke(null, new object[] { url, endResponse }); } }
public static object HttpContext(this IXAFAppWebAPI api) => api.Application.GetPlatform() != Platform.Blazor ? AppDomain.CurrentDomain.Web().HttpContext() : api.GetService("Microsoft.AspNetCore.Http.IHttpContextAccessor").GetPropertyValue("HttpContext");
public static object GetService(this IXAFAppWebAPI api, string serviceType) => api.GetService(AppDomain.CurrentDomain.GetAssemblyType(serviceType));
public static T GetService <T>(this IXAFAppWebAPI api) => (T)api.GetService(typeof(T));