public override IParameterPolicy Create(RoutePatternParameterPart?parameter, string inlineText)
    {
        if (inlineText == null)
        {
            throw new ArgumentNullException(nameof(inlineText));
        }

        var parameterPolicy = ParameterPolicyActivator.ResolveParameterPolicy <IParameterPolicy>(
            _options.ConstraintMap,
            _serviceProvider,
            inlineText,
            out var parameterPolicyKey);

        if (parameterPolicy == null)
        {
            throw new InvalidOperationException(Resources.FormatRoutePattern_ConstraintReferenceNotFound(
                                                    parameterPolicyKey,
                                                    typeof(RouteOptions),
                                                    nameof(RouteOptions.ConstraintMap)));
        }

        if (parameterPolicy is IRouteConstraint constraint)
        {
            return(InitializeRouteConstraint(parameter?.IsOptional ?? false, constraint));
        }

        return(parameterPolicy);
    }
        /// <inheritdoc />
        /// <example>
        /// A typical constraint looks like the following
        /// "exampleConstraint(arg1, arg2, 12)".
        /// Here if the type registered for exampleConstraint has a single constructor with one argument,
        /// The entire string "arg1, arg2, 12" will be treated as a single argument.
        /// In all other cases arguments are split at comma.
        /// </example>
        public virtual IRouteConstraint ResolveConstraint(string inlineConstraint)
        {
            if (inlineConstraint == null)
            {
                throw new ArgumentNullException(nameof(inlineConstraint));
            }

            // This will return null if the text resolves to a non-IRouteConstraint
            return(ParameterPolicyActivator.ResolveParameterPolicy <IRouteConstraint>(
                       _inlineConstraintMap,
                       _serviceProvider,
                       inlineConstraint,
                       out _));
        }