/// <summary>
        /// Ctor
        /// </summary>
        /// <param name="userAgentStringsPath">User agent file path</param>
        /// <param name="crawlerOnlyUserAgentStringsPath">User agent with crawlers only file path</param>
        /// <param name="fileProvider">File provider</param>
        public BrowscapXmlHelper(string userAgentStringsPath, string crawlerOnlyUserAgentStringsPath, IResearchFileProvider fileProvider)
        {
            this._crawlerUserAgentsRegexp = new List <string>();
            this._fileProvider            = fileProvider;

            Initialize(userAgentStringsPath, crawlerOnlyUserAgentStringsPath);
        }
Example #2
0
 public WebHelper(HostingConfig hostingConfig,
                  IHttpContextAccessor httpContextAccessor,
                  IResearchFileProvider fileProvider)
 {
     this._hostingConfig       = hostingConfig;
     this._httpContextAccessor = httpContextAccessor;
     this._fileProvider        = fileProvider;
 }
Example #3
0
 public UserAgentHelper(IHttpContextAccessor httpContextAccessor,
                        IResearchFileProvider fileProvider,
                        ResearchConfig researchConfig)
 {
     this._httpContextAccessor = httpContextAccessor;
     this._fileProvider        = fileProvider;
     this._researchConfig      = researchConfig;
 }
        /// <summary>
        /// Save data settings to the file
        /// </summary>
        /// <param name="settings">Data settings</param>
        /// <param name="fileProvider">File provider</param>
        public static void SaveSettings(DataSettings settings, IResearchFileProvider fileProvider = null)
        {
            Singleton <DataSettings> .Instance = settings ?? throw new ArgumentNullException(nameof(settings));

            fileProvider = fileProvider ?? CommonHelper.DefaultFileProvider;
            var filePath = fileProvider.MapPath(ResearchDataSettingsDefaults.FilePath);

            //create file if not exists
            fileProvider.CreateFile(filePath);

            //save data settings to the file
            var text = JsonConvert.SerializeObject(Singleton <DataSettings> .Instance, Formatting.Indented);

            fileProvider.WriteAllText(filePath, text, Encoding.UTF8);
        }
        /// <summary>
        /// Ctor
        /// </summary>
        /// <param name="seoSettings">SEO settings</param>
        /// <param name="hostingEnvironment">Hosting environment</param>
        /// <param name="cacheManager">Cache manager</param>
        /// <param name="fileProvider">File provider</param>
        public PageHeadBuilder(IHostingEnvironment hostingEnvironment,
                               IStaticCacheManager cacheManager,
                               IResearchFileProvider fileProvider)
        {
            this._hostingEnvironment = hostingEnvironment;
            this._cacheManager       = cacheManager;
            this._fileProvider       = fileProvider;
            this._processor          = new BundleFileProcessor();

            this._titleParts           = new List <string>();
            this._metaDescriptionParts = new List <string>();
            this._metaKeywordParts     = new List <string>();
            this._scriptParts          = new Dictionary <ResourceLocation, List <ScriptReferenceMeta> >();
            this._inlineScriptParts    = new Dictionary <ResourceLocation, List <string> >();
            this._cssParts             = new Dictionary <ResourceLocation, List <CssReferenceMeta> >();
            this._canonicalUrlParts    = new List <string>();
            this._headCustomParts      = new List <string>();
            this._pageCssClassParts    = new List <string>();
        }
Example #6
0
 /// <summary>
 /// Ctor
 /// </summary>
 /// <param name="pictureRepository">Picture repository</param>
 /// <param name="productPictureRepository">Product picture repository</param>
 /// <param name="settingService">Setting service</param>
 /// <param name="webHelper">Web helper</param>
 /// <param name="dbContext">Database context</param>
 /// <param name="eventPublisher">Event publisher</param>
 /// <param name="mediaSettings">Media settings</param>
 /// <param name="dataProvider">Data provider</param>
 /// <param name="fileProvider">File provider</param>
 /// <param name="pictureBinaryRepository">PictureBinary repository</param>
 public PictureService(IRepository <Picture> pictureRepository,
                       IRepository <Researcher> productPictureRepository,
                       ISettingService settingService,
                       IWebHelper webHelper,
                       IDbContext dbContext,
                       IEventPublisher eventPublisher,
                       MediaSettings mediaSettings,
                       IDataProvider dataProvider,
                       IResearchFileProvider fileProvider,
                       IRepository <PictureBinary> pictureBinaryRepository,
                       IRepository <ProjectProgress> projectProgressRepository)
 {
     this._pictureRepository         = pictureRepository;
     this._researcherRepository      = productPictureRepository;
     this._settingService            = settingService;
     this._webHelper                 = webHelper;
     this._dbContext                 = dbContext;
     this._eventPublisher            = eventPublisher;
     this._mediaSettings             = mediaSettings;
     this._dataProvider              = dataProvider;
     this._fileProvider              = fileProvider;
     this._pictureBinaryRepository   = pictureBinaryRepository;
     this._projectProgressRepository = projectProgressRepository;
 }
 public WebAppTypeFinder(IResearchFileProvider fileProvider = null) : base(fileProvider)
 {
 }
 public AppDomainTypeFinder(IResearchFileProvider fileProvider = null)
 {
     this._fileProvider = fileProvider ?? CommonHelper.DefaultFileProvider;
 }
Example #9
0
 public DownloadController(IDownloadService downloadService,
                           IResearchFileProvider fileProvider)
 {
     this._downloadService = downloadService;
     this._fileProvider    = fileProvider;
 }
        /// <summary>
        /// Load data settings
        /// </summary>
        /// <param name="filePath">File path; pass null to use the default settings file</param>
        /// <param name="reloadSettings">Whether to reload data, if they already loaded</param>
        /// <param name="fileProvider">File provider</param>
        /// <returns>Data settings</returns>
        public static DataSettings LoadSettings(string filePath = null, bool reloadSettings = false, IResearchFileProvider fileProvider = null)
        {
            if (!reloadSettings && Singleton <DataSettings> .Instance != null)
            {
                return(Singleton <DataSettings> .Instance);
            }

            fileProvider = fileProvider ?? CommonHelper.DefaultFileProvider;
            filePath     = filePath ?? fileProvider.MapPath(ResearchDataSettingsDefaults.FilePath);

            //check whether file exists
            if (!fileProvider.FileExists(filePath))
            {
                //if not, try to parse the file that was used in previous nopCommerce versions
                filePath = fileProvider.MapPath(ResearchDataSettingsDefaults.ObsoleteFilePath);
                if (!fileProvider.FileExists(filePath))
                {
                    return(new DataSettings());
                }

                //get data settings from the old txt file
                var dataSettings = new DataSettings();
                using (var reader = new StringReader(fileProvider.ReadAllText(filePath, Encoding.UTF8)))
                {
                    string settingsLine;
                    while ((settingsLine = reader.ReadLine()) != null)
                    {
                        var separatorIndex = settingsLine.IndexOf(':');
                        if (separatorIndex == -1)
                        {
                            continue;
                        }

                        var key   = settingsLine.Substring(0, separatorIndex).Trim();
                        var value = settingsLine.Substring(separatorIndex + 1).Trim();

                        switch (key)
                        {
                        case "DataProvider":
                            dataSettings.DataProvider = System.Enum.TryParse(value, true, out DataProviderType providerType) ? providerType : DataProviderType.Unknown;
                            continue;

                        case "DataConnectionString":
                            dataSettings.DataConnectionString = value;
                            continue;

                        default:
                            dataSettings.RawDataSettings.Add(key, value);
                            continue;
                        }
                    }
                }

                //save data settings to the new file
                SaveSettings(dataSettings, fileProvider);

                //and delete the old one
                fileProvider.DeleteFile(filePath);

                Singleton <DataSettings> .Instance = dataSettings;
                return(Singleton <DataSettings> .Instance);
            }

            var text = fileProvider.ReadAllText(filePath, Encoding.UTF8);

            if (string.IsNullOrEmpty(text))
            {
                return(new DataSettings());
            }

            //get data settings from the JSON file
            Singleton <DataSettings> .Instance = JsonConvert.DeserializeObject <DataSettings>(text);

            return(Singleton <DataSettings> .Instance);
        }
Example #11
0
 public EmailSender(IDownloadService downloadService,
                    IResearchFileProvider fileProvider)
 {
     this._downloadService = downloadService;
     this._fileProvider    = fileProvider;
 }
Example #12
0
 public PictureController(IPictureService pictureService,
                          IResearchFileProvider fileProvider)
 {
     this._pictureService = pictureService;
     this._fileProvider   = fileProvider;
 }