예제 #1
0
        public void Apply(BehaviorGraph graph, BehaviorChain chain)
        {
            // Don't override the route if it already exists
            if (chain.Route != null)
            {
                return;
            }

            // Don't override the route if the chain is a partial
            if (chain.IsPartialOnly)
            {
                return;
            }

            var call = chain.Calls.FirstOrDefault();

            if (call == null)
            {
                return;
            }

            var policy = _policies.FirstOrDefault(x => x.Matches(call)) ?? _defaultUrlPolicy;

            call.Trace("First matching UrlPolicy (or default): {0}", policy.GetType().Name);

            var route = policy.Build(call);

            _constraintPolicy.Apply(call, route);

            route.Trace("Route definition determined by url policy: [{0}]", route.ToRoute().Url);

            chain.Route = route;
        }
예제 #2
0
        public void Apply(BehaviorGraph graph, BehaviorChain chain)
        {
            // Don't override the route if it already exists
            if (chain.Route != null)
            {
                return;
            }

            var log = graph.Observer;

            ActionCall call = chain.Calls.FirstOrDefault();

            if (call == null)
            {
                return;
            }

            IUrlPolicy policy = _policies.FirstOrDefault(x => x.Matches(call, log)) ?? _defaultUrlPolicy;

            log.RecordCallStatus(call, "First matching UrlPolicy (or default): {0}".ToFormat(policy.GetType().Name));

            IRouteDefinition route = policy.Build(call);

            _constraintPolicy.Apply(call, route, log);

            log.RecordCallStatus(call, "Route definition determined by url policy: [{0}]".ToFormat(route.ToRoute().Url));
            graph.RegisterRoute(chain, route);
        }