示例#1
0
        /// <summary>
        /// Returns a delegate that will find a StringMatch for a given pattern
        /// where that pattern may be composed of multiple strings
        /// </summary>
        public static GetMatchDelegate GetShowStringDelegates(String fullPattern)
        {
            List <GetMatchDelegate> matchFuncs = new List <GetMatchDelegate>();

            String[] patterns = fullPattern.Split(new char[] { ' ' });
            foreach (String pattern in patterns)
            {
                matchFuncs.Add(GetShowStringDelegate(pattern));
            }

            return((s) =>
            {
                List <StringMatch> matches = new List <StringMatch>();
                foreach (GetMatchDelegate func in matchFuncs)
                {
                    StringMatch match = func(s);
                    matches.Add(match);
                }

                matches.Sort(new MatchComparer());
                return matches.First();
            });
        }