// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Generic; using Microsoft.AspNet.Routing.Constraints; namespace Microsoft.AspNet.Routing { public class RouteOptions { /// /// Gets or sets a value indicating whether all generated URLs are lower-case. /// public bool LowercaseUrls { get; set; } /// /// Gets or sets a value indicating whether a trailing slash should be appended to the generated URLs. /// public bool AppendTrailingSlash { get; set; } private IDictionary _constraintTypeMap = GetDefaultConstraintMap(); public IDictionary ConstraintMap { get { return _constraintTypeMap; } set { if (value == null) { throw new ArgumentNullException(nameof(ConstraintMap)); } _constraintTypeMap = value; } } private static IDictionary GetDefaultConstraintMap() { return new Dictionary(StringComparer.OrdinalIgnoreCase) { // Type-specific constraints { "int", typeof(IntRouteConstraint) }, { "bool", typeof(BoolRouteConstraint) }, { "datetime", typeof(DateTimeRouteConstraint) }, { "decimal", typeof(DecimalRouteConstraint) }, { "double", typeof(DoubleRouteConstraint) }, { "float", typeof(FloatRouteConstraint) }, { "guid", typeof(GuidRouteConstraint) }, { "long", typeof(LongRouteConstraint) }, // Length constraints { "minlength", typeof(MinLengthRouteConstraint) }, { "maxlength", typeof(MaxLengthRouteConstraint) }, { "length", typeof(LengthRouteConstraint) }, // Min/Max value constraints { "min", typeof(MinRouteConstraint) }, { "max", typeof(MaxRouteConstraint) }, { "range", typeof(RangeRouteConstraint) }, // Regex-based constraints { "alpha", typeof(AlphaRouteConstraint) }, { "regex", typeof(RegexInlineRouteConstraint) }, {"required", typeof(RequiredRouteConstraint) }, }; } /// /// Gets or sets the value that enables best-effort link generation. /// /// If enabled, link generation will use allow link generation to succeed when the set of values provided /// cannot be validated. /// public bool UseBestEffortLinkGeneration { get; set; } } }