示例#1
0
        public IEnumerable <Command> TransformStartMenu(StartMenu startMenu)
        {
            string matchedSelector;

            // Apply to uncategorized items
            foreach (var item in startMenu.Get(""))
            {
                string catStr = FindCategory(item, false, out matchedSelector);
                if (catStr == null)
                {
                    continue;
                }

                var newCategory = startMenu.GetOrCreate(catStr);
                yield return(new MoveProgramItemCommand(item, newCategory, matchedSelector));
            }

            // Apply to restricted items
            foreach (var restrictedCat in this.Where(cat => cat.IsRestricted))
            {
                var programCategory = startMenu.GetOrLoad(restrictedCat.RestrictedPath);
                if (programCategory == null)
                {
                    continue;
                }

                foreach (var item in programCategory)
                {
                    foreach (var catItem in restrictedCat.Where(catItem => catItem.RegexObject.IsMatch(item.Name)))
                    {
                        var newCategory = startMenu.GetOrCreate(restrictedCat.Name);
                        yield return(new MoveProgramItemCommand(item, newCategory, catItem.Value));

                        break;
                    }
                }
            }
        }