Esempio n. 1
0
        public DefaultRouteCache(INancyModuleCatalog moduleCatalog, IModuleKeyGenerator moduleKeyGenerator)
        {
            _ModuleKeyGenerator = moduleKeyGenerator;
            _Cache = new List<RouteCacheEntry>();

            BuildCache(moduleCatalog.GetAllModules());
        }
Esempio n. 2
0
 public override IList <SwaggerRouteData> RetrieveSwaggerRouteData()
 {
     return(_moduleCatalog
            .GetAllModules(_context)
            .SelectMany(ToSwaggerRouteData)
            .ToList());
 }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
 public void RebuildCache()
 {
     this.Clear();
     using (var context = contextFactory.Create())
     {
         this.BuildCache(moduleCatalog.GetAllModules(context));
     }
 }
Esempio n. 5
0
        /// <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));
            }
        }
Esempio n. 6
0
        /// <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));
            }
        }
Esempio n. 7
0
        /// <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);
        }
Esempio n. 9
0
        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);
        }