public ScheduleProvider(IWebHostEnvironment webHostEnvironment, RouteProvider routeProvider) { fileCache = new LocalJsonFile <ScheduleData>(webHostEnvironment.ContentRootFileProvider, "schedule.json"); if (fileCache.CacheExists()) { schedules = fileCache.Load().Result?.Select(scheduleData => scheduleData.ToDailyRouteSchedule(routeProvider)).ToList() ?? new List <DailyRouteSchedule>(); } }
public RouteProvider(IConfiguration configuration, IWebHostEnvironment webHostEnvironment) { var fileCache = new LocalJsonFile <RouteInfo>(webHostEnvironment.ContentRootFileProvider, "routes.json"); refreshAction = (force) => { IEnumerable <RouteInfo> routes = null; if (fileCache.CacheExists()) { routes = fileCache.Load().Result; } if (force || routes == null) { routes = new RouteWebProvider(configuration).GetRoutesFromWeb().Result; fileCache.Save(routes); } allRoutes = routes.ToDictionary(info => RouteInfo.GetWebFriendlyName(info.Name)); }; refreshAction(false); }