public SpiderMiddleware(RequestDelegate next, IActionDescriptorCollectionProvider routeProvider,
                                IRouteDataService routeDataService, IPluginHelperService pluginHelperService,
                                IPluginTypesService pluginTypesService, ISettingsProvider settingsProvider)
        {
            if (routeProvider == null)
            {
                throw new ArgumentNullException(nameof(routeProvider));
            }

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

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

            _next = next;

            _userSessionManagerLoaded = pluginHelperService.PluginLoaded("UserSessionMiddleware.Plugin.dll", out int version);

            _deniedSpiderRoutes = new List <DeniedRoute>();
            LoadSpiderData(routeProvider, routeDataService, pluginTypesService);

            SpiderSettings settings = settingsProvider.GetSettings <SpiderSettings>("Spider.Plugin");

            _processStaticFiles = settings.ProcessStaticFiles;

            if (!String.IsNullOrEmpty(settings.StaticFileExtensions))
            {
                _staticFileExtensions = settings.StaticFileExtensions;
            }
        }
        public ShoppingCartMiddleware(RequestDelegate next, IShoppingCartService shoppingCartService,
                                      ISettingsProvider settingsProvider, ILogger logger, IPluginHelperService pluginHelperService)
        {
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

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

            _next = next;
            _shoppingCartService = shoppingCartService ?? throw new ArgumentNullException(nameof(shoppingCartService));

            if (pluginHelperService == null || !pluginHelperService.PluginLoaded(Constants.PluginNameUserSession, out int version))
            {
                logger.AddToLog(LogLevel.Error,
                                new Exception(Constants.UserSessionServiceNotFound),
                                nameof(ShoppingCartMiddleware));
            }

            _cartSettings = settingsProvider.GetSettings <CartSettings>(Constants.ShoppingCart);
        }
Exemple #3
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 #4
0
        public AccountController(ISettingsProvider settingsProvider, IAccountProvider accountProvider,
                                 IDownloadProvider downloadProvider, ICountryProvider countryProvider,
                                 ILicenceProvider licenceProvider, IUserCultureChangeProvider userCultureChanged,
                                 ICultureProvider cultureProvider, IPluginHelperService pluginHelperService)
        {
            _settingsProvider   = settingsProvider ?? throw new ArgumentNullException(nameof(settingsProvider));
            _accountProvider    = accountProvider ?? throw new ArgumentNullException(nameof(accountProvider));
            _downloadProvider   = downloadProvider ?? throw new ArgumentNullException(nameof(downloadProvider));
            _licenceProvider    = licenceProvider ?? throw new ArgumentNullException(nameof(licenceProvider));
            _userCultureChanged = userCultureChanged ?? throw new ArgumentNullException(nameof(userCultureChanged));
            _cultureProvider    = cultureProvider ?? throw new ArgumentNullException(nameof(cultureProvider));

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

            if (Countries == null)
            {
                Countries = countryProvider.GetVisibleCountries();
            }

            if (LicenceTypes == null)
            {
                LicenceTypes = _licenceProvider.LicenceTypesGet();
            }

            _blogLoaded = pluginHelperService.PluginLoaded("Blog.Plugin.dll", out _);
        }
        public BadEggMiddleware(RequestDelegate next, IActionDescriptorCollectionProvider routeProvider,
                                IRouteDataService routeDataService, IPluginHelperService pluginHelperService,
                                IPluginTypesService pluginTypesService, IIpValidation ipValidation,
                                ISettingsProvider settingsProvider, INotificationService notificationService)
        {
            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 (pluginTypesService == null)
            {
                throw new ArgumentNullException(nameof(pluginTypesService));
            }

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

            _next = next;

            _userSessionManagerLoaded = pluginHelperService.PluginLoaded(Constants.PluginNameUserSession, out int version);
            _ipValidation             = ipValidation ?? throw new ArgumentNullException(nameof(ipValidation));
            _notificationService      = notificationService ?? throw new ArgumentNullException(nameof(notificationService));

            _managedRoutes = new List <ManagedRoute>();
            LoadRouteData(routeProvider, routeDataService, pluginTypesService);

            _badEggSettings = settingsProvider.GetSettings <BadEggSettings>("BadEgg.Plugin");

            _validateConnections = new ValidateConnections(
                _badEggSettings.ConnectionTimeOut,
                _badEggSettings.ConnectionsPerMinute);
            _validateConnections.ConnectionAdd      += ValidateConnections_ConnectionAdd;
            _validateConnections.ConnectionRemove   += ValidateConnections_ConnectionRemove;
            _validateConnections.OnReportConnection += ValidateConnections_OnReportConnection;
            _validateConnections.OnBanIPAddress     += ValidateConnections_OnBanIPAddress;

            ThreadManager.ThreadStart(_validateConnections, "Bad Egg Validation", ThreadPriority.Lowest);
        }
        public void TestAddAssembly()
        {
            IPluginHelperService pluginServices = UnitTestHelper.GetPluginServices();

            Assembly current = Assembly.GetExecutingAssembly();

            DynamicLoadResult loadResult = pluginServices.AddAssembly(current);

            Assert.IsTrue(loadResult == DynamicLoadResult.Success);

            pluginServices.PluginLoaded(System.IO.Path.GetFileName(current.Location), out int version);

            Assert.IsTrue(version == 1);
        }
Exemple #7
0
        public ProductController(IProductProvider productProvider, ISettingsProvider settingsProvider,
                                 IPluginHelperService pluginHelper, IStockProvider stockProvider)
        {
            if (settingsProvider == null)
            {
                throw new ArgumentNullException(nameof(settingsProvider));
            }

            ProductControllerSettings settings = settingsProvider.GetSettings <ProductControllerSettings>("Products");

            _productProvider = productProvider ?? throw new ArgumentNullException(nameof(productProvider));
            _stockProvider   = stockProvider ?? throw new ArgumentNullException(nameof(stockProvider));
            _productsPerPage = settings.ProductsPerPage;
            _hasShoppingCart = pluginHelper.PluginLoaded(SharedPluginFeatures.Constants.PluginNameShoppingCart, out _);
        }