Example #1
0
        /// <summary>
        ///     Creates a new <see cref="ILogEntryFilter" /> from the given values.
        /// </summary>
        /// <param name="value"></param>
        /// <param name="matchType"></param>
        /// <param name="ignoreCase"></param>
        /// <param name="isInverted"></param>
        /// <returns></returns>
        public static ILogEntryFilter Create(string value, FilterMatchType matchType, bool ignoreCase, bool isInverted)
        {
            ILogEntryFilter filter = null;

            switch (matchType)
            {
            case FilterMatchType.SubstringFilter:
                if (!string.IsNullOrEmpty(value))
                {
                    filter = new SubstringFilter(value, ignoreCase);
                }
                break;

            case FilterMatchType.WildcardFilter:
                if (!string.IsNullOrEmpty(value))
                {
                    filter = new WildcardFilter(value, ignoreCase);
                }
                break;

            case FilterMatchType.RegexpFilter:
                if (!string.IsNullOrEmpty(value))
                {
                    filter = new RegexFilter(value, ignoreCase);
                }
                break;
            }

            if (filter != null && isInverted)
            {
                filter = new InvertFilter(filter);
            }

            return(filter);
        }
Example #2
0
        /// <summary>
        ///     Creates a new <see cref="ILogEntryFilter" /> from the given values.
        /// </summary>
        /// <param name="substringFilter"></param>
        /// <returns></returns>
        public static ILogEntryFilter Create(string substringFilter)
        {
            var filter = new SubstringFilter(substringFilter, ignoreCase: true);

            return(filter);
        }