예제 #1
0
        public IEnumerable<RouteBase> BuildRoute(IServiceFactory factory, SessionStateRequirement defaultSessionRequirement, BehaviorChain chain)
        {
            yield return buildRoute(factory, defaultSessionRequirement, chain, chain.Route);

            foreach (var alias in chain.AdditionalRoutes)
            {
                yield return buildRoute(factory, defaultSessionRequirement, chain, alias);
            }
        }
예제 #2
0
        public RouteBase BuildRoute(IBehaviorFactory factory, SessionStateRequirement defaultSessionRequirement, BehaviorChain chain)
        {
            var requiresSession = chain.Route.SessionStateRequirement ?? defaultSessionRequirement;

            var route = chain.Route.ToRoute();
            var handlerSource = DetermineHandlerSource(requiresSession, chain);
            var invoker = DetermineInvoker(factory, chain);

            route.RouteHandler = new FubuRouteHandler(invoker, handlerSource);

            return route;
        }
예제 #3
0
        private RouteBase buildRoute(IServiceFactory factory, SessionStateRequirement defaultSessionRequirement,
            BehaviorChain chain, IRouteDefinition routeDefinition)
        {
            var requiresSession = routeDefinition.SessionStateRequirement ?? defaultSessionRequirement;

            var route = routeDefinition.ToRoute();
            var handlerSource = DetermineHandlerSource(requiresSession, chain);
            var invoker = DetermineInvoker(factory, chain);

            route.RouteHandler = new FubuRouteHandler(invoker, handlerSource);

            return route;
        }
예제 #4
0
        public static IHttpHandlerSource DetermineHandlerSource(SessionStateRequirement sessionStateRequirement, BehaviorChain chain)
        {
            if (chain.IsAsynchronous())
            {
                return sessionStateRequirement == SessionStateRequirement.RequiresSessionState
                           ? (IHttpHandlerSource) new AsynchronousHttpHandlerSource()
                           : new SessionlessAsynchronousHttpHandlerSource();
            }

            return sessionStateRequirement == SessionStateRequirement.RequiresSessionState
                       ? (IHttpHandlerSource)new SynchronousHttpHandlerSource()
                       : new SessionlessSynchronousHttpHandlerSource();
        }
예제 #5
0
        void DescribesItself.Describe(Description description)
        {
            description.Title = "Route:  " + Pattern;
            if (_input != null)
            {
                description.Children["Input"] = Description.For(_input);
            }

            if (_constraints.Any())
            {
                description.AddList("Constraints", _constraints);
            }

            description.Properties["Http Verbs"] = AllowedHttpMethods.Any() ? AllowedHttpMethods.Join(", ") : "Any";

            description.Properties["SessionStateRequirement"] = SessionStateRequirement == null
                                                                    ? "Default"
                                                                    : SessionStateRequirement.ToString();
        }
예제 #6
0
 public static IHttpHandlerSource DetermineHandlerSource(SessionStateRequirement sessionStateRequirement, BehaviorChain chain)
 {
     return(sessionStateRequirement == SessionStateRequirement.RequiresSessionState
                ? (IHttpHandlerSource) new AsynchronousHttpHandlerSource()
                : new SessionlessAsynchronousHttpHandlerSource());
 }