示例#1
0
        /// <summary>
        /// Return the fragments that match against the given <param name="itemToMatch"/>
        /// </summary>
        /// <param name="matches">
        /// Total number of matches. Some fragments match more than once (item expression may contain multiple instances of <param name="itemToMatch"/>)
        /// </param>
        public IEnumerable <ItemFragment> FragmentsMatchingItem(string itemToMatch, out int matches)
        {
            var result = new List <ItemFragment>(Fragments.Count());

            matches = 0;

            foreach (var fragment in Fragments)
            {
                var itemMatches = fragment.ItemMatches(itemToMatch);

                if (itemMatches > 0)
                {
                    result.Add(fragment);
                    matches += itemMatches;
                }
            }

            return(result);
        }