private static SegmentMatch CreateMatch(string parameterName, object matchedValue)
        {
            var match = new SegmentMatch(true);

            match.CapturedParameters.Add(parameterName, matchedValue);
            return(match);
        }
Esempio n. 2
0
        private SegmentMatch CreateMatch(object value)
        {
            var match = new SegmentMatch(true);

            match.CapturedParameters.Add(this.parameterName, value);
            return(match);
        }
        /// <summary>
        /// Matches the segment for a requested route
        /// </summary>
        /// <param name="segment">Segment string</param>
        /// <returns>A <see cref="SegmentMatch"/> instance representing the result of the match</returns>
        public override SegmentMatch Match(string segment)
        {
            var match = new SegmentMatch(true);

            match.CapturedParameters[this.parameterName] = segment;
            return(match);
        }
Esempio n. 4
0
        public override SegmentMatch Match(string segment)
        {
            var match = new SegmentMatch(true);

            match.CapturedParameters.Add(_parameterName, segment);
            return(match);
        }
 /// <summary>
 /// Matches the segment for a requested route
 /// </summary>
 /// <param name="segment">Segment string</param>
 /// <returns>A <see cref="SegmentMatch"/> instance representing the result of the match</returns>
 public override SegmentMatch Match(string segment)
 {
     var match = SegmentMatch.NoMatch;
       if (segment.StartsWith(this.preLiteral) && segment.EndsWith(this.postLiteral))
       {
     match = new SegmentMatch(true);
     match.CapturedParameters.Add(this.parameterName, segment.Substring(this.preLiteral.Length, segment.Length - this.postLiteral.Length - this.preLiteral.Length));
       }
       return match;
 }
Esempio n. 6
0
        /// <summary>
        /// Matches the segment for a requested route
        /// </summary>
        /// <param name="segment">Segment string</param>
        /// <returns>A <see cref="SegmentMatch"/> instance representing the result of the match</returns>
        public override SegmentMatch Match(string segment)
        {
            var match = SegmentMatch.NoMatch;

            if (segment.StartsWith(this.preLiteral) && segment.EndsWith(this.postLiteral))
            {
                match = new SegmentMatch(true);
                match.CapturedParameters.Add(this.parameterName, segment.Substring(this.preLiteral.Length, segment.Length - this.postLiteral.Length - this.preLiteral.Length));
            }
            return(match);
        }
        /// <summary>
        /// Matches the segment for a requested route
        /// </summary>
        /// <param name="segment">Segment string</param>
        /// <returns>A <see cref="SegmentMatch"/> instance representing the result of the match</returns>
        public override SegmentMatch Match(string segment)
        {
            var match = SegmentMatch.NoMatch;
            var regex = new Regex(builtRegex);

            if (regex.IsMatch(segment))
            {
                match = new SegmentMatch(true);
                var regexMatch = regex.Match(segment);
                for (var i = 1; i < regexMatch.Groups.Count; i++)
                {
                    match.CapturedParameters.Add(parameterNames[i - 1], regexMatch.Groups[i].Value);
                }
            }
            return match;
        }
        /// <summary>
        /// Matches the segment for a requested route
        /// </summary>
        /// <param name="segment">Segment string</param>
        /// <returns>A <see cref="SegmentMatch"/> instance representing the result of the match</returns>
        public override SegmentMatch Match(string segment)
        {
            var match = SegmentMatch.NoMatch;
            var regex = new Regex(this.builtRegex, StaticConfiguration.CaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase);

            if (regex.IsMatch(segment))
            {
                match = new SegmentMatch(true);
                var regexMatch = regex.Match(segment);
                for (var i = 1; i < regexMatch.Groups.Count; i++)
                {
                    match.CapturedParameters.Add(parameterNames[i - 1], regexMatch.Groups[i].Value);
                }
            }
            return(match);
        }
        /// <summary>
        /// Matches the segment for a requested route
        /// </summary>
        /// <param name="segment">Segment string</param>
        /// <returns>A <see cref="SegmentMatch"/> instance representing the result of the match</returns>
        public override SegmentMatch Match(string segment)
        {
            var match = SegmentMatch.NoMatch;
            var regex = new Regex(builtRegex);

            if (regex.IsMatch(segment))
            {
                match = new SegmentMatch(true);
                var regexMatch = regex.Match(segment);
                for (var i = 1; i < regexMatch.Groups.Count; i++)
                {
                    match.CapturedParameters.Add(parameterNames[i - 1], regexMatch.Groups[i].Value);
                }
            }
            return(match);
        }
        /// <summary>
        /// Matches the segment for a requested route
        /// </summary>
        /// <param name="segment">Segment string</param>
        /// <returns>A <see cref="SegmentMatch"/> instance representing the result of the match</returns>
        public override SegmentMatch Match(string segment)
        {
            var match = SegmentMatch.NoMatch;
            var regex = new Regex(this.builtRegex, StaticConfiguration.CaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase);

            if (regex.IsMatch(segment))
            {
                match = new SegmentMatch(true);
                var regexMatch = regex.Match(segment);
                for (var i = 1; i < regexMatch.Groups.Count; i++)
                {
                    match.CapturedParameters.Add(parameterNames[i - 1], regexMatch.Groups[i].Value);
                }
            }
            return match;
        }
        /// <summary>
        /// Matches the segment for a requested route
        /// </summary>
        /// <param name="segment">Segment string</param>
        /// <returns>A <see cref="SegmentMatch"/> instance representing the result of the match</returns>
        public override SegmentMatch Match(string segment)
        {
            var match = this.expression.Match(segment);

            if (!match.Success)
            {
                return SegmentMatch.NoMatch;
            }

            var result = new SegmentMatch(true);
            foreach (var groupName in this.groupNames)
            {
                var group = match.Groups[groupName];
                if (group.Success)
                {
                    result.CapturedParameters[groupName] = group.Value;
                }
            }

            return result;
        }
Esempio n. 12
0
        /// <summary>
        /// Matches the segment for a requested route
        /// </summary>
        /// <param name="segment">Segment string</param>
        /// <returns>A <see cref="SegmentMatch"/> instance representing the result of the match</returns>
        public override SegmentMatch Match(string segment)
        {
            var match = this.expression.Match(segment);

            if (!match.Success)
            {
                return SegmentMatch.NoMatch;
            }

            var result = new SegmentMatch(true);
            foreach (var groupName in this.groupNames)
            {
                var group = match.Groups[groupName];
                if (group.Success)
                {
                    result.CapturedParameters[groupName] = group.Value;
                }
            }

            return result;
        }
Esempio n. 13
0
        /// <summary>
        /// Matches the segment for a requested route
        /// </summary>
        /// <param name="segment">Segment string</param>
        /// <returns>A <see cref="SegmentMatch"/> instance representing the result of the match</returns>
        public override SegmentMatch Match(string segment)
        {
            var match = SegmentMatch.NoMatch;
            var regex = new Regex(this.builtRegex, StaticConfiguration.CaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase);

            if (regex.IsMatch(segment))
            {
                match = new SegmentMatch(true);
                var regexMatch = regex.Match(segment);
                for (var i = 1; i < regexMatch.Groups.Count; i++)
                {
                    match.CapturedParameters.Add(this.parameterNames[i - 1], regexMatch.Groups[i].Value);
                    if (!string.IsNullOrEmpty(this.constraints[i - 1]))
                    {
                        var routeSegmentConstraint = this.routeSegmentConstraints.FirstOrDefault(x => x.Matches(constraints[i - 1]));
                        if (routeSegmentConstraint == null || !routeSegmentConstraint.GetMatch(this.constraints[i - 1], regexMatch.Groups[i].Value, this.parameterNames[i - 1]).Matches)
                        {
                            return(SegmentMatch.NoMatch);
                        }
                    }
                }
            }
            return(match);
        }
        /// <summary>
        /// Matches the segment for a requested route
        /// </summary>
        /// <param name="segment">Segment string</param>
        /// <returns>A <see cref="SegmentMatch"/> instance representing the result of the match</returns>
        public override SegmentMatch Match(string segment)
        {
            var match = SegmentMatch.NoMatch;
            var regex = new Regex(this.builtRegex, StaticConfiguration.CaseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase);

            if (regex.IsMatch(segment))
            {
                match = new SegmentMatch(true);
                var regexMatch = regex.Match(segment);
                for (var i = 1; i < regexMatch.Groups.Count; i++)
                {
                    match.CapturedParameters.Add(this.parameterNames[i - 1], regexMatch.Groups[i].Value);
                    if (!string.IsNullOrEmpty(this.constraints[i - 1]))
                    {
                        var routeSegmentConstraint = this.routeSegmentConstraints.FirstOrDefault(x => x.Matches(constraints[i-1]));
                        if (routeSegmentConstraint == null || !routeSegmentConstraint.GetMatch(this.constraints[i - 1], regexMatch.Groups[i].Value, this.parameterNames[i - 1]).Matches)
                        {
                            return SegmentMatch.NoMatch;
                        }
                    }
                }
            }
            return match;
        }
Esempio n. 15
0
 /// <summary>
 /// Matches the segment for a requested route
 /// </summary>
 /// <param name="segment">Segment string</param>
 /// <returns>A <see cref="SegmentMatch"/> instance representing the result of the match</returns>
 public override SegmentMatch Match(string segment)
 {
     var match = new SegmentMatch(true);
     match.CapturedParameters.Add(this.parameterName, segment);
     return match;
 }
Esempio n. 16
0
 private SegmentMatch CreateMatch(object value)
 {
     var match = new SegmentMatch(true);
     match.CapturedParameters.Add(this.parameterName, value);
     return match;
 }