Exemple #1
0
        public BreadcrumbMiddleware(RequestDelegate next, IActionDescriptorCollectionProvider routeProvider,
                                    IRouteDataService routeDataService, IPluginHelperService pluginHelperService,
                                    IPluginTypesService pluginTypesService, ISettingsProvider settingsProvider,
                                    IPluginClassesService pluginClassesService, ILogger logger)
        {
            if (routeProvider == null)
            {
                throw new ArgumentNullException(nameof(routeProvider));
            }

            if (routeDataService == null)
            {
                throw new ArgumentNullException(nameof(routeDataService));
            }

            if (pluginHelperService == null)
            {
                throw new ArgumentNullException(nameof(pluginHelperService));
            }

            if (pluginClassesService == null)
            {
                throw new ArgumentNullException(nameof(pluginClassesService));
            }

            if (pluginTypesService == null)
            {
                throw new ArgumentNullException(nameof(pluginTypesService));
            }

            if (settingsProvider == null)
            {
                throw new ArgumentNullException(nameof(settingsProvider));
            }

            _next   = next;
            _logger = logger ?? throw new ArgumentNullException(nameof(logger));

            if (pluginHelperService.PluginLoaded(Constants.PluginNameLocalization, out int _))
            {
                List <IStringLocalizer> stringLocalizers = pluginClassesService.GetPluginClasses <IStringLocalizer>();

                if (stringLocalizers.Count > 0)
                {
                    _stringLocalizer = stringLocalizers[0];
                }
            }

            BreadcrumbSettings settings = settingsProvider.GetSettings <BreadcrumbSettings>(Constants.PluginSettingBreadcrumb);

            _homeBreadCrumb = new BreadcrumbItem(settings.HomeName,
                                                 $"{Constants.ForwardSlash}{settings.HomeController}{Constants.ForwardSlash}{settings.DefaultAction}", false);

            LoadBreadcrumbData(routeProvider, routeDataService, pluginTypesService, settings);

            if (!String.IsNullOrEmpty(settings.StaticFileExtensions))
            {
                _staticFileExtensions = settings.StaticFileExtensions;
            }
        }
Exemple #2
0
        public BreadcrumbService(ISettingsProvider settingsProvider)
        {
            if (settingsProvider == null)
            {
                throw new ArgumentNullException(nameof(settingsProvider));
            }

            BreadcrumbSettings settings = settingsProvider.GetSettings <BreadcrumbSettings>(Constants.PluginSettingBreadcrumb);

            _homeName       = settings.HomeName;
            _homeController = settings.HomeController;
            _defaultMethod  = settings.DefaultAction;
        }