public DefaultRouteCache(INancyModuleCatalog moduleCatalog, IModuleKeyGenerator moduleKeyGenerator) { _ModuleKeyGenerator = moduleKeyGenerator; _Cache = new List<RouteCacheEntry>(); BuildCache(moduleCatalog.GetAllModules()); }
public override IList <SwaggerRouteData> RetrieveSwaggerRouteData() { return(_moduleCatalog .GetAllModules(_context) .SelectMany(ToSwaggerRouteData) .ToList()); }
public RoutesModel(NancyContext ctx, INancyModuleCatalog catalog) { var routes = from module in catalog.GetAllModules(ctx) from route in module.Routes select new RouteModel(module, route); this.AddRange(routes); }
public void RebuildCache() { this.Clear(); using (var context = contextFactory.Create()) { this.BuildCache(moduleCatalog.GetAllModules(context)); } }
/// <summary> /// Initializes a new instance of the <see cref="RouteCache"/> class. /// </summary> /// <param name="moduleCatalog">The <see cref="INancyModuleCatalog"/> that should be used by the cache.</param> /// <param name="moduleKeyGenerator">The <see cref="IModuleKeyGenerator"/> used to generate module keys.</param> /// <param name="contextFactory">The <see cref="INancyContextFactory"/> that should be used to create a context instance.</param> public RouteCache(INancyModuleCatalog moduleCatalog, IModuleKeyGenerator moduleKeyGenerator, INancyContextFactory contextFactory) { this.moduleKeyGenerator = moduleKeyGenerator; using (var context = contextFactory.Create()) { this.BuildCache(moduleCatalog.GetAllModules(context)); } }
/// <summary> /// Initializes a new instance of the <see cref="RouteCache"/> class. /// </summary> /// <param name="moduleCatalog">The <see cref="INancyModuleCatalog"/> that should be used by the cache.</param> /// <param name="moduleKeyGenerator">The <see cref="IModuleKeyGenerator"/> used to generate module keys.</param> /// <param name="contextFactory">The <see cref="INancyContextFactory"/> that should be used to create a context instance.</param> /// <param name="routeSegmentExtractor"> </param> public RouteCache(INancyModuleCatalog moduleCatalog, IModuleKeyGenerator moduleKeyGenerator, INancyContextFactory contextFactory, IRouteSegmentExtractor routeSegmentExtractor, IRouteDescriptionProvider routeDescriptionProvider) { this.moduleKeyGenerator = moduleKeyGenerator; this.routeSegmentExtractor = routeSegmentExtractor; this.routeDescriptionProvider = routeDescriptionProvider; using (var context = contextFactory.Create()) { this.BuildCache(moduleCatalog.GetAllModules(context)); } }
/// <summary> /// Initializes a new instance of the <see cref="RouteCache"/> class. /// </summary> /// <param name="moduleCatalog">The <see cref="INancyModuleCatalog"/> that should be used by the cache.</param> /// <param name="contextFactory">The <see cref="INancyContextFactory"/> that should be used to create a context instance.</param> /// <param name="routeSegmentExtractor"> </param> public RouteCache(INancyModuleCatalog moduleCatalog, INancyContextFactory contextFactory, IRouteSegmentExtractor routeSegmentExtractor, IRouteDescriptionProvider routeDescriptionProvider, ICultureService cultureService) { this.routeSegmentExtractor = routeSegmentExtractor; this.routeDescriptionProvider = routeDescriptionProvider; var request = new Request("GET", "/", "http"); using (var context = contextFactory.Create(request)) { this.BuildCache(moduleCatalog.GetAllModules(context)); } }
protected override IDictionary <string, SwaggerRouteData> RetrieveSwaggerPaths(NancyContext context) { var pathItems = new Dictionary <string, SwaggerRouteData>(); foreach (var pair in _moduleCatalog .GetAllModules(context) .SelectMany(ToSwaggerRouteData)) { SwaggerRouteData entry; if (pathItems.TryGetValue(pair.Path, out entry)) { pathItems[pair.Path] = entry.Combine(pair); } else { pathItems.Add(pair.Path, pair); } } return(pathItems); }
protected override IDictionary <string, PathItem> RetrieveSwaggerRouteData() { var pathItems = new Dictionary <string, PathItem>(); foreach (var pair in _moduleCatalog .GetAllModules(_context) .SelectMany(ToSwaggerRouteData)) { PathItem entry; if (pathItems.TryGetValue(pair.Item1, out entry)) { pathItems[pair.Item1] = entry.Combine(pair.Item2); } else { pathItems.Add(pair.Item1, pair.Item2); } } return(pathItems); }