Пример #1
0
        /// <summary>
        /// Given a set of route values, extracts any necessary values that would be used by this segment.
        /// </summary>
        /// <param name="route">The route.</param>
        /// <param name="values">The values.</param>
        /// <returns>
        /// An object that indicates whether the values were successfully matched.
        /// </returns>
        public override SegmentValueMatch MatchValues(IRoute route, RouteValueBag values)
        {
            var value = values.Take(parameterName);

            if (value == UrlParameter.NotSpecified)
            {
                if (defaultValue != UrlParameter.NotSpecified)
                {
                    return(SegmentValueMatch.Successful(defaultValue));
                }
                return(SegmentValueMatch.Successful());
            }

            return(SegmentValueMatch.Successful(value));
        }
        /// <summary>
        /// Given a set of route values, extracts any necessary values that would be used by this segment.
        /// </summary>
        /// <param name="route">The route.</param>
        /// <param name="values">The values.</param>
        /// <returns>
        /// An object that indicates whether the values were successfully matched.
        /// </returns>
        public override SegmentValueMatch MatchValues(IRoute route, RouteValueBag values)
        {
            var value = values.Take(parameterName);

            if (value == UrlParameter.NotSpecified)
            {
                if (defaultValue != UrlParameter.NotSpecified)
                {
                    return(SegmentValueMatch.Successful(defaultValue));
                }
                return(SegmentValueMatch.Failure(string.Format("A value for the parameter '{0}' was not provided", parameterName)));
            }

            return(SegmentValueMatch.Successful(value));
        }
Пример #3
0
 /// <summary>
 /// Given a set of route values, extracts any necessary values that would be used by this segment.
 /// </summary>
 /// <param name="route">The route.</param>
 /// <param name="values">The values.</param>
 /// <returns>
 /// An object that indicates whether the values were successfully matched.
 /// </returns>
 public override SegmentValueMatch MatchValues(IRoute route, RouteValueBag values)
 {
     return(SegmentValueMatch.Successful(literal));
 }