Example #1
0
        private static ITreeItem[] Build(string rootPath, Action <double?, string> progress)
        {
            var        roots        = Directory.EnumerateDirectories(rootPath, "*", SearchOption.TopDirectoryOnly);
            FolderItem root         = new FolderItem(rootPath);
            double     rateProgress = 1.0 / roots.Count();
            int        current      = 0;

            foreach (string viewFolder in roots)
            {
                current++;
                progress(current * rateProgress, null);
                progress(null, "Folder: " + viewFolder + "\r\n\r\n\r\n");
                var            files      = Directory.EnumerateFiles(viewFolder, "*.sln", SearchOption.AllDirectories);
                var            folderItem = new FolderItem(Path.Combine(rootPath, viewFolder));
                SolutionItem[] slns       = files.Select(x => TryCreateSolution(x, folderItem, progress)).Where(x => x != null).ToArray();
                if (slns.Length > 0)
                {
                    folderItem.Children.AddRange(slns);
                    root.Children.Add(folderItem);
                }
            }
            return(root.Children.ToArray());
        }