Пример #1
0
        public int CompareTo(object obj)
        {
            FavoriteFileGroup tempO = obj as FavoriteFileGroup;

            if (tempO == null)
            {
                throw new ArgumentException("Object is not FavoriteFileGroup");
            }

            return(this.Name.CompareTo(tempO.Name));
        }
Пример #2
0
        private void ResolveFavoriteGroups()
        {
            FavoriteFileGroup ungrouped = new FavoriteFileGroup("Ungrouped");

            this.favoriteFiles.BubbleSort();

            foreach (FavoriteFile ffile in this.favoriteFiles)
            {
                bool inserted = false;
                foreach (FavoriteFileGroup group in this.favoriteFileFroups)
                {
                    if (string.Compare(group.Name, ffile.GroupName, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        group.Files.Add(ffile);
                        inserted = true;
                        break;
                    }
                }

                if (!inserted)
                {
                    if (string.IsNullOrEmpty(ffile.GroupName))
                    {
                        ungrouped.Files.Add(ffile);
                    }
                    else
                    {
                        FavoriteFileGroup nogroup = new FavoriteFileGroup(ffile.GroupName);
                        nogroup.Files.Add(ffile);
                        this.favoriteFileFroups.Add(nogroup);
                    }
                }
            }

            if (ungrouped.Files.Count > 0)
            {
                this.favoriteFileFroups.Add(ungrouped);
            }
        }