/// <summary>
        /// Creates a new instance of <see cref="CurrentPageProvider" />.
        /// </summary>
        /// <param name="actionContextAccessor">Action context accessor</param>
        /// <param name="pageTreeProvider">Page tree provider</param>
        public CurrentPageProvider(IActionContextAccessor actionContextAccessor, PageTreeProvider pageTreeProvider)
        {
            this.actionContextAccessor = actionContextAccessor ?? throw new ArgumentNullException(nameof(actionContextAccessor));
            this.pageTreeProvider      = pageTreeProvider ?? throw new ArgumentNullException(nameof(pageTreeProvider));

            Build();
        }
Beispiel #2
0
        /// <summary>
        /// Adds the AspNetCore page tree provider
        /// </summary>
        /// <param name="services">Service collection</param>
        /// <param name="controllersAssembly">Assembly to read Route attributes in controllers from</param>
        /// <returns>Service collection</returns>
        public static IServiceCollection AddPageTree(this IServiceCollection services, Assembly controllersAssembly)
        {
            var provider = new PageTreeProvider(controllersAssembly);

            services.AddSingleton(provider);
            services.AddSingleton <IPageTreeProvider>(provider);
            services.AddScoped <ICurrentPageProvider, CurrentPageProvider>();
            return(services);
        }