예제 #1
0
        private static List <DriveObject> SearchDrivesHelper(List <DriveObject> foundObjects, DriveObject currentNode, string searchParameter, ref int SearchCount, FilterOptions options)
        {
            if (currentNode != null)
            {
                switch (options.searchFilter)
                {
                case SearchFilter.Name:
                {
                    string nodeName = "";
                    if (!options.exactMatch)
                    {
                        nodeName = currentNode.name.ToLower();
                    }
                    else
                    {
                        nodeName = currentNode.name;
                    }

                    if (nodeName.Contains(searchParameter))
                    {
                        foundObjects.Add(currentNode);
                    }
                    break;
                }

                case SearchFilter.Tag:
                {
                    if (currentNode.getTags().Contains(new Tag(searchParameter)))
                    {
                        foundObjects.Add(currentNode);
                    }

                    break;
                }
                }

                SearchCount++;

                foreach (DriveObject child in currentNode.getSubDirectories())
                {
                    SearchDrivesHelper(foundObjects, child, searchParameter, ref SearchCount, options);
                }
                // Any Filter Options go here \/
            }
            return(foundObjects);
        }
예제 #2
0
        public static List <List <DriveObject> > SearchDrives(string searchParamter, ref int SearchCount, FilterOptions options)
        {
            if (!options.exactMatch && options.searchFilter == SearchFilter.Name)
            {
                searchParamter = searchParamter.ToLower();
            }
            List <List <DriveObject> > sortedFoundObjects = new List <List <DriveObject> >();

            for (int i = 0; i < DriveData.Count; i++)
            {
                if (options.SpecifyDrives && i != options.DriveIndex)
                {
                    continue;
                }
                List <DriveObject> foundObjects = new List <DriveObject>();
                SearchDrivesHelper(foundObjects, DriveData.ElementAt(i), searchParamter, ref SearchCount, options);
                sortedFoundObjects.Add(foundObjects);
            }
            return(sortedFoundObjects);
        }