New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update RoutePatternFactory.Pattern to allow a list of parameter policies for a key #6588

Closed
JamesNK opened this Issue Jan 11, 2019 · 3 comments

Comments

Projects
None yet
3 participants
@JamesNK
Copy link
Member

JamesNK commented Jan 11, 2019

RoutePatternFactory.Pattern takes dictionary for extra parameter policies.

Key = policy name
Value = policy

Because this is a dictionary, only one policy can be provided for a name. It would be useful to also support an enumerable of policies for a key.

Inspired by - #6587 (comment)

/// <summary>
/// Creates a <see cref="RoutePattern"/> from a collection of segments along
/// with provided default values and parameter policies.
/// </summary>
/// <param name="defaults">
/// Additional default values to associated with the route pattern. May be null.
/// The provided object will be converted to key-value pairs using <see cref="RouteValueDictionary"/>
/// and then merged into the route pattern.
/// </param>
/// <param name="parameterPolicies">
/// Additional parameter policies to associated with the route pattern. May be null.
/// The provided object will be converted to key-value pairs using <see cref="RouteValueDictionary"/>
/// and then merged into the route pattern.
/// </param>
/// <param name="segments">The collection of segments.</param>
/// <returns>The <see cref="RoutePattern"/>.</returns>
public static RoutePattern Pattern(
object defaults,
object parameterPolicies,
IEnumerable<RoutePatternPathSegment> segments)
{
if (segments == null)
{
throw new ArgumentNullException(nameof(segments));
}
return PatternCore(null, new RouteValueDictionary(defaults), new RouteValueDictionary(parameterPolicies), requiredValues: null, segments);
}

// @rynowak

@rynowak

This comment has been minimized.

Copy link
Member

rynowak commented Jan 11, 2019

Seems like a good enhancement, is this blocking?

@JamesNK

This comment has been minimized.

Copy link
Member

JamesNK commented Jan 11, 2019

I don't think it is for the linked 2.2 patch

@rynowak

This comment has been minimized.

Copy link
Member

rynowak commented Jan 11, 2019

OK good, because I don't think we would patch this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment