Question: TemplateMatcher and InlineConstraint · Issue #362 · aspnet/Routing (original) (raw)

This repository was archived by the owner on Nov 27, 2018. It is now read-only.

This repository was archived by the owner on Nov 27, 2018. It is now read-only.

@dodyg

Description

@dodyg

Does TemplateMatcher ignore the InlineConstraints specified in a TemplatePart by design?

            var segment = new TemplateSegment();
            segment.Parts.Add(TemplatePart.CreateLiteral("page"));

            var segment2 = new TemplateSegment();
            segment2.Parts.Add(TemplatePart.CreateParameter("id",
               isCatchAll: false,
               isOptional: false,
               defaultValue: null,
               inlineConstraints: new InlineConstraint[] { new InlineConstraint("int") }));

            var segments = new TemplateSegment[] {
                segment,
                segment2
            };

            var template = new RouteTemplate("page", segments.ToList());
            var templateMatcher = new TemplateMatcher(template, new RouteValueDictionary());

The templateMatcher at above code will return true for both /page/10 and /page/BBB.

Full code is here