Пример #1
0
 public bool FilterBy(string Input)
 {
     if (Input[0] == '-')
     {
         return(!SearchString.Contains(Input.Substring(1).Trim()));
     }
     else
     {
         return(SearchString.Contains(Input));
     }
 }
Пример #2
0
        public void OnGet()
        {
            if (String.IsNullOrWhiteSpace(SearchString))
            {
                Products = productData.GetAllProducts();
            }
            else
            {
                if (SearchString.Contains("/"))
                {
                    Products = productData.GetProductsByProductCode(SearchString);
                    if (Products.Any())
                    {
                        return;
                    }
                }

                Products = productData.GetProductsByName(SearchString);
            }
        }
Пример #3
0
            public bool     DescriptionContains(SearchString str)
            {
                int index = Description.Length - str.Search.Length;

                while (index >= 0)
                {
                    if (!str.Contains(Description[index]))
                    {
                        index -= str.Search.Length;
                    }
                    else if (Description.Substring(index, str.Search.Length) == str.Search)
                    {
                        return(true);
                    }
                    else
                    {
                        index -= 1;
                    }
                }

                return(false);
            }
Пример #4
0
 public bool Filter(string filter)
 {
     return(SearchString.Contains(filter));
 }
        public object ExecuteSearch()
        {
            if (string.IsNullOrEmpty(SearchString))
            {
                return(null);
            }

            string path;
            string keyword;
            var    includesPath = IncludesPath(out path, out keyword);

            if (includesPath == SearchStringType.NoPath)
            {
                keyword = SearchString;
            }

            List <string> allAvailablepaths = new List <string>();

            //HashMap<string, List<string>> tempFiles = new HashMap<string, List<string>>();
            List <string> paths = null;
            //Regex regex = new Regex(keyword);
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();

            for (int i = 0; i < _drives.Count; i++)
            {
                foreach (var key in filesOfAllDrives[i].Keys)
                {
                    if (IsMatch(keyword, key, SearchString.Contains('*')))
                    {
                        filesOfAllDrives[i].TryGetValue(key, out paths);

                        if (paths != null)
                        {
                            allAvailablepaths.AddRange(paths);
                        }
                    }
                }
            }

            if (!(includesPath == SearchStringType.NoPath))
            {
                List <string> tempAvailablepaths = new List <string>(allAvailablepaths);
                allAvailablepaths.Clear();
                foreach (var eachFilePath in tempAvailablepaths)
                {
                    if (IsMatch(path, eachFilePath, false))
                    {
                        allAvailablepaths.Add(eachFilePath);
                    }
                }
            }

            Files = allAvailablepaths;

            //GetFilesFromPath(SearchString, tempFiles);
            stopWatch.Stop();
            Console.WriteLine("GetFilesFromPath" + stopWatch.Elapsed);

            Messages = "About " +
                       (allAvailablepaths == null ? 0.ToString() : allAvailablepaths.Count().ToString()) +
                       " results found in " + stopWatch.Elapsed.TotalSeconds.ToString("n2") + " second";

            return(null);
        }