private ObservableCollection <VsModule> GetDuplicateModulesFromModuleCollection()
 {
     return(ModuleCollection.Where(module =>
                                   ModuleCollection
                                   .Except(new ObservableCollection <VsModule> {
         module
     })
                                   .Any(x => x.Name == module.Name)
                                   ).ToObservableCollection());
 }
        public void DoClassification()
        {
            if (string.IsNullOrWhiteSpace(SelectedFolderPath))
            {
                return;
            }

            ModuleCollection.Clear();
            OldVersionModule.Clear();

            DirectoryInfo dirInfo = new DirectoryInfo(SelectedFolderPath);

            if (dirInfo != null && !dirInfo.Exists)
            {
                Properties.Settings.Default.LastSelectedFolder = "";
                SelectedFolderPath = "";
                return;
            }

            //classification
            DirectoryInfo archiveDirectoryInfo = null;
            var           directories          = dirInfo.GetDirectories();

            foreach (var directory in directories)
            {
                var vsModule = new VSModule();
                if (directory.Name.Contains(","))
                {
                    var stringSplit = directory.Name.Split(',').ToList();
                    vsModule.Name    = stringSplit.FirstOrDefault();
                    vsModule.Version = stringSplit[1];
                    stringSplit.Remove(vsModule.Name);
                    stringSplit.Remove(vsModule.Version);
                    if (stringSplit.Count() > 0)
                    {
                        foreach (var item in stringSplit)
                        {
                            vsModule.Name = vsModule.Name + "," + item;
                        }
                    }
                }
                else if (directory.Name.Equals("Archive"))
                {
                    archiveDirectoryInfo = directory;
                }
                else
                {
                    continue;
                }
                vsModule.FullPath = directory.FullName;
                ModuleCollection.Add(vsModule);
            }

            //Select all the Modules with same name from ModuleCollection
            var duplicateModules =
                ModuleCollection.Where(module =>
                                       ModuleCollection
                                       .Except(new ObservableCollection <VSModule> {
                module
            })
                                       .Any(x => x.Name == module.Name)
                                       ).ToObservableCollection();

            //Get all the old version modules/folder from duplicateModules
            OldVersionModule =
                duplicateModules.Where(module =>
                                       duplicateModules
                                       .Except(new ObservableCollection <VSModule> {
                module
            })
                                       .Any(x => x.Name == module.Name && x.VersionObject.CompareTo(module.VersionObject) > 0)
                                       ).ToObservableCollection();

            //Add archive folder to old version module
            if (archiveDirectoryInfo != null)
            {
                OldVersionModule.Add(new VSModule()
                {
                    FullPath = archiveDirectoryInfo.FullName,
                    Name     = archiveDirectoryInfo.Name
                });
            }
        }