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);
        }
Esempio n. 2
0
 public void RegisterUrlPolicy(IUrlPolicy policy, bool prepend)
 {
     if (prepend)
     {
         _policies.Insert(0, policy);
     }
     else
     {
         _policies.Add(policy);
     }
 }
 public RouteConventionExpression UrlPolicy(IUrlPolicy policy)
 {
     alter(x => x.RegisterUrlPolicy(policy));
     return(this);
 }
Esempio n. 4
0
 public void RegisterUrlPolicy(IUrlPolicy policy)
 {
     RegisterUrlPolicy(policy, false);
 }
Esempio n. 5
0
 public RouteConventionExpression UrlPolicy(IUrlPolicy policy)
 {
     _resolver.RegisterUrlPolicy(policy);
     return(this);
 }
 public void RegisterUrlPolicy(IUrlPolicy policy)
 {
     _policies.Add(policy);
 }
 public void RegisterUrlPolicy(IUrlPolicy policy, bool prepend)
 {
     if (prepend)
     {
         _policies.Insert(0, policy);
     }
     else
     {
         _policies.Add(policy);
     }
 }
 public void RegisterUrlPolicy(IUrlPolicy policy)
 {
     RegisterUrlPolicy(policy, false);
 }
        public static IRouteDefinition CreateRoute <T>(this IUrlPolicy policy, Expression <Func <T, object> > action)
        {
            var actionCall = new ActionCall(typeof(T), typeof(T).GetMethod(((MethodCallExpression)action.Body).Method.Name));

            return(policy.Build(actionCall));
        }
 public AllStringOutputRoutesAreSpecialPolicy(IUrlPolicy innerUrlPolicy)
 {
     _innerUrlPolicy = innerUrlPolicy;
 }