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); }