Exemple #1
0
        public static bool ItemNameHasAllKeywordsFrom(this FolderTreeItem item, SortedDictionary <string, string> allowedKeywords)
        {
            var matches = KeywordsRegex.Matches(item.ItemNameWithoutExtension.ToLower());

            for (var i = 0; i < matches.Count; i++)
            {
                var keyword = matches[i].Value;

                if (allowedKeywords.ContainsKey(keyword) == false)
                {
                    return(false);
                }
            }

            return(true);
        }
        private void AddItem(FolderTreeItem item)
        {
            if (item.IsFile)
            {
                if (_files == null)
                {
                    _files = new Dictionary <string, FileItem>();
                }

                _files.Add(item.ItemPath.ToLower(), (FileItem)item);
            }
            else
            {
                if (_folders == null)
                {
                    _folders = new Dictionary <string, FolderItem>();
                }

                _folders.Add(item.ItemPath.ToLower(), (FolderItem)item);
            }

            AddParentFolder(item.ParentFolder);
        }
Exemple #3
0
        public bool TryGetItem(string itemName, out FolderTreeItem treeItem)
        {
            FolderItem folderItem;

            if (TryGetFolder(itemName, out folderItem))
            {
                treeItem = folderItem;

                return(true);
            }

            FileItem fileItem;

            if (TryGetFile(itemName, out fileItem))
            {
                treeItem = fileItem;

                return(true);
            }

            treeItem = null;

            return(false);
        }
Exemple #4
0
 public FolderTreeItemAttribute(FolderTreeItem item, T value)
 {
     Item  = item;
     Value = value;
 }
Exemple #5
0
        public static IEnumerable <FolderTreeItemAttribute <string> > ItemNameKeywords(this FolderTreeItem item, SortedDictionary <string, string> allowedKeywords)
        {
            var keywords = new List <string>();

            var matches = KeywordsRegex.Matches(item.ItemNameWithoutExtension.ToLower());

            for (var i = 0; i < matches.Count; i++)
            {
                var keyword = matches[i].Value;

                if (allowedKeywords.ContainsKey(keyword))
                {
                    keywords.Add(matches[i].Value);
                }
            }

            return
                (keywords
                 .Distinct()
                 .Select(value => new FolderTreeItemAttribute <string>(item, value)));
        }