コード例 #1
0
ファイル: DefaultRouteCache.cs プロジェクト: tt/Nancy
        public DefaultRouteCache(INancyModuleCatalog moduleCatalog, IModuleKeyGenerator moduleKeyGenerator)
        {
            _ModuleKeyGenerator = moduleKeyGenerator;
            _Cache = new List<RouteCacheEntry>();

            BuildCache(moduleCatalog.GetAllModules());
        }
コード例 #2
0
 public override IList <SwaggerRouteData> RetrieveSwaggerRouteData()
 {
     return(_moduleCatalog
            .GetAllModules(_context)
            .SelectMany(ToSwaggerRouteData)
            .ToList());
 }
コード例 #3
0
ファイル: RoutesModel.cs プロジェクト: jchannon/Glimpse.Nancy
        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);
        }
コード例 #4
0
 public void RebuildCache()
 {
     this.Clear();
     using (var context = contextFactory.Create())
     {
         this.BuildCache(moduleCatalog.GetAllModules(context));
     }
 }
コード例 #5
0
ファイル: RouteCache.cs プロジェクト: williware/Nancy
        /// <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));
            }
        }
コード例 #6
0
ファイル: RouteCache.cs プロジェクト: rstat1/Nancy
        /// <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));
            }
        }
コード例 #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));
            }
        }
コード例 #8
0
        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);
        }
コード例 #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);
        }