using Microsoft.AspNetCore.Mvc; using Nop.Core; using Nop.Core.Domain.Seo; using Nop.Core.Infrastructure; namespace Nop.Web.Framework.Mvc.Routing; /// /// Represents url helper extension methods /// public static class UrlHelperExtensions { /// /// Generate a generic URL for the specified entity type and route values /// /// Entity type that supports slug /// URL helper /// An object that contains route values /// The protocol for the URL, such as "http" or "https" /// The host name for the URL /// The fragment for the URL /// The generated URL public static string RouteUrl(this IUrlHelper urlHelper, object values = null, string protocol = null, string host = null, string fragment = null) where TEntity : BaseEntity, ISlugSupported { var nopUrlHelper = EngineContext.Current.Resolve(); return nopUrlHelper.RouteGenericUrlAsync(values, protocol, host, fragment).Result; } /// /// Generate a URL for topic by the specified system name /// /// URL helper /// Topic system name /// The protocol for the URL, such as "http" or "https" /// The host name for the URL /// The fragment for the URL /// The generated URL public static string RouteTopicUrl(this IUrlHelper urlHelper, string systemName, string protocol = null, string host = null, string fragment = null) { var nopUrlHelper = EngineContext.Current.Resolve(); return nopUrlHelper.RouteTopicUrlAsync(systemName, protocol, host, fragment).Result; } }