コード例 #1
0
ファイル: Bootstrapper.cs プロジェクト: gaochundong/Happer
        private RequestDispatcher BuildRequestDispatcher(IModuleContainer container)
        {
            var moduleCatalog = new ModuleCatalog(
                    () => { return container.GetAllModules(); },
                    (Type moduleType) => { return container.GetModule(moduleType); }
                );

            var routeSegmentExtractor = new RouteSegmentExtractor();
            var routeDescriptionProvider = new RouteDescriptionProvider();
            var routeCache = new RouteCache(routeSegmentExtractor, routeDescriptionProvider);
            routeCache.BuildCache(moduleCatalog.GetAllModules());

            var trieNodeFactory = new TrieNodeFactory();
            var routeTrie = new RouteResolverTrie(trieNodeFactory);
            routeTrie.BuildTrie(routeCache);

            var serializers = new List<ISerializer>() { new JsonSerializer(), new XmlSerializer() };
            var responseFormatterFactory = new ResponseFormatterFactory(serializers);
            var moduleBuilder = new ModuleBuilder(responseFormatterFactory);

            var routeResolver = new RouteResolver(moduleCatalog, moduleBuilder, routeTrie);

            var negotiator = new ResponseNegotiator();
            var routeInvoker = new RouteInvoker(negotiator);
            var requestDispatcher = new RequestDispatcher(routeResolver, routeInvoker);

            return requestDispatcher;
        }
コード例 #2
0
ファイル: Engine.cs プロジェクト: gaochundong/Happer
        public Engine(StaticContentProvider staticContentProvider, RequestDispatcher requestDispatcher)
        {
            if (staticContentProvider == null)
                throw new ArgumentNullException("staticContentProvider");
            if (requestDispatcher == null)
                throw new ArgumentNullException("requestDispatcher");

            _staticContentProvider = staticContentProvider;
            _requestDispatcher = requestDispatcher;
        }