Webiant Logo Webiant Logo
  1. No results found.

    Try your search with a different keyword or use * as a wildcard.

PageRenderingEvent.cs

using Nop.Web.Framework.UI;

namespace Nop.Web.Framework.Events;

/// 
/// Represents a page rendering event
/// 
public partial class PageRenderingEvent
{
    #region Ctor

    /// 
    /// Ctor
    /// 
    /// HTML Helper
    /// Overridden route name
    public PageRenderingEvent(INopHtmlHelper helper, string overriddenRouteName = null)
    {
        Helper = helper;
        OverriddenRouteName = overriddenRouteName;
    }

    #endregion

    #region Properties

    /// 
    /// Gets HTML helper
    /// 
    public INopHtmlHelper Helper { get; protected set; }

    /// 
    /// Gets overridden route name
    /// 
    public string OverriddenRouteName { get; protected set; }

    #endregion

    #region Methods

    /// 
    /// Get the route name associated with the request rendering this page
    /// 
    /// A value indicating whether to build the name using engine information unless otherwise specified
    /// Route name
    public string GetRouteName(bool handleDefaultRoutes = false)
    {
        //if an overridden route name is specified, then use it
        //we use it to specify a custom route name when some custom page uses a custom route. But we still need this event to be invoked
        if (!string.IsNullOrEmpty(OverriddenRouteName))
            return OverriddenRouteName;

        //or try to get a registered endpoint route name
        return Helper.GetRouteName(handleDefaultRoutes);
    }

    #endregion
}