CheckForKeyWords() static private method

static private CheckForKeyWords ( string searchString, SearchFilter filter, int quote1, int quote2 ) : bool
searchString string
filter SearchFilter
quote1 int
quote2 int
return bool
Ejemplo n.º 1
0
        internal static bool ParseSearchString(string searchText, SearchFilter filter)
        {
            bool result;

            if (string.IsNullOrEmpty(searchText))
            {
                result = false;
            }
            else
            {
                filter.ClearSearch();
                string text = string.Copy(searchText);
                SearchUtility.RemoveUnwantedWhitespaces(ref text);
                bool flag = false;
                int  i    = SearchUtility.FindFirstPositionNotOf(text, " \t,*?");
                if (i == -1)
                {
                    i = 0;
                }
                while (i < text.Length)
                {
                    int num  = text.IndexOfAny(" \t,*?".ToCharArray(), i);
                    int num2 = text.IndexOf('"', i);
                    int num3 = -1;
                    if (num2 != -1)
                    {
                        num3 = text.IndexOf('"', num2 + 1);
                        if (num3 != -1)
                        {
                            num = text.IndexOfAny(" \t,*?".ToCharArray(), num3);
                        }
                        else
                        {
                            num = -1;
                        }
                    }
                    if (num == -1)
                    {
                        num = text.Length;
                    }
                    if (num > i)
                    {
                        string text2 = text.Substring(i, num - i);
                        if (SearchUtility.CheckForKeyWords(text2, filter, num2, num3))
                        {
                            flag = true;
                        }
                        else
                        {
                            filter.nameFilter = filter.nameFilter + ((!string.IsNullOrEmpty(filter.nameFilter)) ? " " : "") + text2;
                        }
                    }
                    i = num + 1;
                }
                result = flag;
            }
            return(result);
        }
Ejemplo n.º 2
0
        internal static bool ParseSearchString(string searchText, SearchFilter filter)
        {
            if (string.IsNullOrEmpty(searchText))
            {
                return(false);
            }
            filter.ClearSearch();
            string searchString1 = string.Copy(searchText);

            SearchUtility.RemoveUnwantedWhitespaces(ref searchString1);
            bool flag       = false;
            int  startIndex = SearchUtility.FindFirstPositionNotOf(searchString1, " \t,");

            if (startIndex == -1)
            {
                startIndex = 0;
            }
            int num1;

            for (; startIndex < searchString1.Length; startIndex = num1 + 1)
            {
                num1 = searchString1.IndexOfAny(" \t,".ToCharArray(), startIndex);
                int quote1 = searchString1.IndexOf('"', startIndex);
                int num2   = -1;
                if (quote1 != -1)
                {
                    num2 = searchString1.IndexOf('"', quote1 + 1);
                    num1 = num2 == -1 ? -1 : searchString1.IndexOfAny(" \t,".ToCharArray(), num2);
                }
                if (num1 == -1)
                {
                    num1 = searchString1.Length;
                }
                if (num1 > startIndex)
                {
                    string searchString2 = searchString1.Substring(startIndex, num1 - startIndex);
                    if (SearchUtility.CheckForKeyWords(searchString2, filter, quote1, num2))
                    {
                        flag = true;
                    }
                    else
                    {
                        SearchFilter searchFilter = filter;
                        string       str          = searchFilter.nameFilter + (!string.IsNullOrEmpty(filter.nameFilter) ? " " : string.Empty) + searchString2;
                        searchFilter.nameFilter = str;
                    }
                }
            }
            return(flag);
        }