public CacheLessRuntimeContentService(IContentPathMapper pathMapper, ISearchService searchService) { SearchService = searchService; PathMapper = pathMapper; Urls = new List<string>(); _lock = new object(); _lastUrlFlush = DateTime.Now; _urlPath = Path.Combine(PathMapper.ContentRootFolder("/"), "sitemap-urls.json"); if (!File.Exists(_urlPath)) return; var urls = File.ReadAllText(_urlPath); Urls = JsonConvert.DeserializeObject<List<string>>(urls); }
public async Task RefreshUrls() { IList <string> urls = new List <string>(); var files = await this._fileProvider.List(PathMapper.ContentRootFolder("/"), "*.json", true); foreach (var file in files) { if (file.Contains(SITEMAP_FILE)) { continue; } var content = await FromFile(file); urls.Add(content.Url); } Urls = urls; FlushUrls(); }
public CacheLessRuntimeContentService(string path, string[] domains, IFileProvider fileProvider) { this._domains = domains; //SearchService = searchService; this._fileProvider = fileProvider; PathMapper = new ContentPathMapper(path, fileProvider); Urls = new List <string>(); _lock = new object(); _lastUrlFlush = DateTime.Now; _urlPath = this._fileProvider.Combine(PathMapper.ContentRootFolder("/"), SITEMAP_FILE); if (!this._fileProvider.Exists(_urlPath)) { return; } var urls = this._fileProvider.ReadAllText(_urlPath).Result; Urls = JsonConvert.DeserializeObject <IList <string> >(urls); }