예제 #1
0
        public static IRouteBuilder MapGreedyContentRoute(
            this IRouteBuilder routeBuilder,
            string name,
            string templatePrefix,
            object defaults,
            object constraints = null,
            object dataTokens  = null)
        {
            IInlineConstraintResolver requiredService   = routeBuilder.ServiceProvider.GetRequiredService <IInlineConstraintResolver>();
            IControllerMapper         controllerMapper  = routeBuilder.ServiceProvider.GetRequiredService <IControllerMapper>();
            ITargetingFilterAccessor  targetingAccessor = routeBuilder.ServiceProvider.GetService <ITargetingFilterAccessor>();
            IHeadUrlResolver          headUrlResolver   = routeBuilder.ServiceProvider.GetService <IHeadUrlResolver>();

            var template        = CreateRouteTemplate(templatePrefix);
            var constraintsDict = ObjectToDictionary(constraints);

            constraintsDict.Add(TailRouteTokenName, new GreedyRouteConstraint(TailRouteTokenName));

            var route = new GreedyContentRoute(controllerMapper, targetingAccessor, headUrlResolver,
                                               routeBuilder.DefaultHandler,
                                               name,
                                               template,
                                               new RouteValueDictionary(defaults),
                                               constraintsDict,
                                               new RouteValueDictionary(dataTokens),
                                               requiredService);

            routeBuilder.Routes.Add(route);

            return(routeBuilder);
        }
예제 #2
0
 public ContentRoute(IControllerMapper controllerMapper,
                     ITargetingFilterAccessor targetingProvider,
                     IHeadUrlResolver headUrlResolver,
                     IRouter target,
                     string routeTemplate,
                     IInlineConstraintResolver inlineConstraintResolver)
     : this(controllerMapper, targetingProvider, headUrlResolver, target, routeTemplate, null, null, null, inlineConstraintResolver)
 {
 }
 public SiteStructureRouteValueTransformer(ITargetingFilterAccessor targetingFilterAccessor,
                                           IControllerMapper controllerMapper,
                                           ITailUrlResolver tailUrlResolver,
                                           IHeadUrlResolver headUrlResolver)
 {
     TargetingFilterAccessor = targetingFilterAccessor;
     ControllerMapper        = controllerMapper;
     TailUrlResolver         = tailUrlResolver;
     HeadUrlResolver         = headUrlResolver;
 }
예제 #4
0
 public ContentRoute(IControllerMapper controllerMapper,
                     ITargetingFilterAccessor targetingProvider,
                     IHeadUrlResolver headUrlResolver,
                     IRouter target,
                     string routeTemplate,
                     RouteValueDictionary defaults,
                     IDictionary <string, object> constraints,
                     RouteValueDictionary dataTokens,
                     IInlineConstraintResolver inlineConstraintResolver)
     : this(controllerMapper, targetingProvider, headUrlResolver, target, null, routeTemplate, defaults, constraints, dataTokens, inlineConstraintResolver)
 {
 }
예제 #5
0
 public AbstractContentRoute(
     IControllerMapper controllerMapper,
     ITargetingFilterAccessor targetingProvider,
     IHeadUrlResolver headUrlResolver,
     IRouter target,
     string routeName,
     string routeTemplate,
     RouteValueDictionary defaults,
     IDictionary <string, object> constraints,
     RouteValueDictionary dataTokens,
     IInlineConstraintResolver inlineConstraintResolver)
     : base(target, routeName, routeTemplate, defaults, constraints, dataTokens, inlineConstraintResolver)
 {
     ControllerMapper  = controllerMapper;
     TargetingProvider = targetingProvider;
     HeadUrlResolver   = headUrlResolver;
 }
        public static IRouteBuilder MapContentRoute(this IRouteBuilder routes, string name, string template, object defaults, object constraints, object dataTokens)
        {
            IInlineConstraintResolver requiredService      = routes.ServiceProvider.GetRequiredService <IInlineConstraintResolver>();
            IControllerMapper         controllerMapper     = routes.ServiceProvider.GetRequiredService <IControllerMapper>();
            ITargetingFilterAccessor  targetingAccessor    = routes.ServiceProvider.GetService <ITargetingFilterAccessor>();
            IHeadUrlResolver          targetingUrlResolver = routes.ServiceProvider.GetService <IHeadUrlResolver>();

            routes.Routes.Add(new ContentRoute(controllerMapper, targetingAccessor, targetingUrlResolver,
                                               routes.DefaultHandler,
                                               name,
                                               template,
                                               new RouteValueDictionary(defaults),
                                               new RouteValueDictionary(constraints),
                                               new RouteValueDictionary(dataTokens),
                                               requiredService));

            return(routes);
        }
 public UrlTokenTargetingProvider(IHttpContextAccessor httpContextAccessor, IHeadUrlResolver urlResolver)
 {
     _httpContextAccessor = httpContextAccessor;
     _urlResolver         = urlResolver;
 }
 public TargetingUrlTransformator(ITargetingContext targetingContext, IHeadUrlResolver urlResolver)
 {
     _targetingContext = targetingContext;
     _urlResolver      = urlResolver;
 }
예제 #9
0
        public PathData Find(string path, IStartPage root, ITargetingFilter targetingFilter, IHeadUrlResolver urlResolver)
        {
            path = urlResolver.SanitizeUrl(path);

            var tokens = path.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);

            if (tokens.Length == 0)
            {
                return(new PathData(root, path));
            }

            IAbstractItem stopItem      = root;
            IAbstractItem node          = root;
            string        remainingPath = path;
            int           index         = 0;

            foreach (var token in tokens)
            {
                if (StopCondition != null && StopCondition(node))
                {
                    break;
                }
                node = node.GetChildPageByAlias(token, targetingFilter);
                if (node == null)
                {
                    break;
                }
                index++;
                stopItem      = node;
                remainingPath = $"/{string.Join("/", tokens.Select((x, i) => i < index ? (string)null : x).Where(x => x != null))}";
            }

            return(new PathData(stopItem, remainingPath));
        }