object MatchClass(string text) { Match m = regex.Match(text); Type fieldType = memberInfo is FieldInfo ? ((FieldInfo)memberInfo).FieldType : ((PropertyInfo)memberInfo).PropertyType; if (fieldType.IsArray) { ArrayList matches = new ArrayList(); int matchCount = 0; while (m.Success && matchCount < maxRepeats) { if (m.Groups.Count <= group) { throw BadGroupIndexException(group, memberInfo.Name, m.Groups.Count - 1); } Group g = m.Groups[group]; foreach (Capture c in g.Captures) { matches.Add(matchType.Match(text.Substring(c.Index, c.Length))); } m = m.NextMatch(); matchCount++; } return(matches.ToArray(matchType.Type)); } else { if (m.Success) { if (m.Groups.Count <= group) { throw BadGroupIndexException(group, memberInfo.Name, m.Groups.Count - 1); } Group g = m.Groups[group]; if (g.Captures.Count > 0) { if (g.Captures.Count <= capture) { throw BadCaptureIndexException(capture, memberInfo.Name, g.Captures.Count - 1); } Capture c = g.Captures[capture]; return(matchType.Match(text.Substring(c.Index, c.Length))); } } return(null); } }
/// <include file='doc\PatternMatcher.uex' path='docs/doc[@for="PatternMatcher.Match"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public object Match(string text) { return(matchType.Match(text)); }