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 Uri GetRequestUri(this IXAFAppWebAPI api) => (Uri)(api.Application.GetPlatform() == Platform.Blazor ? new Uri(AppDomain.CurrentDomain.GetAssemblyType("Microsoft.AspNetCore.Http.Extensions.UriHelper").Method("GetDisplayUrl", Flags.StaticPublic).Call(null, api.HttpContext().GetPropertyValue("Request")).ToString()) : api.HttpContext().GetPropertyValue("Request").GetPropertyValue("Url"));
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 object GetService(this IXAFAppWebAPI api, Type serviceType) => api.Application.GetPropertyValue("ServiceProvider").CallMethod("GetService", serviceType);
public static T GetService <T>(this IXAFAppWebAPI api) => (T)api.GetService(typeof(T));
public static void SetPageError(this IXAFAppWebAPI api, Exception exception) => api.Application.HandleException(exception);
public static object GetService(this IXAFAppWebAPI api, Type serviceType) => api.Application.GetPlatform() == Platform.Blazor? api.Application.GetPropertyValue("ServiceProvider")?.CallMethod("GetService", serviceType):null;