示例#1
0
        private static IEnumerable <string> parseValues(Card card, int propertyIndex)
        {
            string text           = KeywordDefinitions.Getters[propertyIndex](card);
            var    propertyValues = KeywordDefinitions.Values[propertyIndex];
            var    patterns       = KeywordDefinitions.Patterns[propertyIndex];

            if (string.IsNullOrEmpty(text))
            {
                yield break;
            }

            for (int j = 0; j < propertyValues.Count; j++)
            {
                if (patterns[j] == null)
                {
                    continue;
                }

                if (patterns[j].IsMatch(text))
                {
                    string displayText = KeywordRegexUtil.GetKeywordDisplayText(propertyValues[j]);
                    yield return(displayText);
                }
            }
        }
示例#2
0
        static KeywordDefinitions()
        {
            Patterns = Enumerable.Range(0, Values.Count)
                       .Select(i => Values[i].Select(PatternFactories[i]).ToList())
                       .Cast <IList <Regex> >()
                       .ToList();

            PatternsByDisplayText =
                Enumerable.Range(0, Values.Count)
                .Select(i => Enumerable.Range(0, Patterns[i].Count)
                        .Where(j => Values[i][j] != null)
                        .ToDictionary(
                            j => KeywordRegexUtil.GetKeywordDisplayText(Values[i][j]),
                            j => Patterns[i][j],
                            Str.Comparer))
                .ToList();

            KeywordsIndex     = PropertyNames.IndexOf(nameof(Keywords));
            CastKeywordsIndex = PropertyNames.IndexOf(nameof(CastKeywords));
        }