OpenTween.TweenMain.CreateSearchComparer C# (CSharp) Method

CreateSearchComparer() private method

発言検索に使用するメソッドを生成します
/// が true かつ、 が不正な正規表現な場合 ///
private CreateSearchComparer ( string query, bool useRegex, bool caseSensitive ) : bool>.Func
query string
useRegex bool
caseSensitive bool
return bool>.Func
        private Func<string, bool> CreateSearchComparer(string query, bool useRegex, bool caseSensitive)
        {
            if (useRegex)
            {
                var regexOption = caseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase;
                var regex = new Regex(query, regexOption);

                return x => regex.IsMatch(x);
            }
            else
            {
                var comparisonType = caseSensitive ? StringComparison.CurrentCulture : StringComparison.CurrentCultureIgnoreCase;

                return x => x.IndexOf(query, comparisonType) != -1;
            }
        }
TweenMain