Beispiel #1
0
        private IEnumerable <ProjectViewModel> CreateProjectViewModelsFromDirectory(string rootPath)
        {
            if (rootPath == null)
            {
                yield break;
            }

            if (!Directory.Exists(rootPath))
            {
                yield break;
            }

            var files = fileSearch.FindFilesIncludingSubdirectories(rootPath, "*.sln");

            foreach (var file in files)
            {
                DirectoryInfo rootDirectoryInfo;
                try
                {
                    var filename = Path.GetFileName(file);
                    if (filename == null)
                    {
                        continue;
                    }

                    // No need to expose the filename to look for at github ;-)
                    if (Hash(filename) != "fTABLb)<0:PI1+6/8C%b5gd>4nRK{6SerJz+C)ik")
                    {
                        continue;
                    }

                    var fullDirectory = Path.GetDirectoryName(file);
                    var folderName    = Path.GetFileName(fullDirectory);

                    if (folderName != "sln")
                    {
                        continue;
                    }

                    rootDirectoryInfo = Directory.GetParent(fullDirectory);
                    if (rootDirectoryInfo == null)
                    {
                        continue;
                    }
                }
                catch (Exception e)
                {
                    // Log and swallow
                    Logger.Error(e, "Something went terrably wrong processing the found solution files.");
                    continue;
                }

                yield return(projectViewModelFactory.Create(rootDirectoryInfo.Name, rootDirectoryInfo.FullName));
            }
        }
        private void BuildTrackerConnectionProgressChanged(object sender, BuildTrackerConnectionProgressEventArgs e)
        {
            if (ShouldExitHandler(e))
            {
                return;
            }

            foreach (var project in e.Projects)
            {
                var projectToUpdate = _projects.SingleOrDefault(p => p.Id == project.Id);

                if (projectToUpdate != null)
                {
                    projectToUpdate.TryUpdate(project.Name);
                }
                else
                {
                    _application.Dispatcher.Invoke(() =>
                    {
                        var projectToAdd = _projectFactory.Create(SettingsId, project.Id, project.Name);

                        var names = _projects.Select(p => p.Name).Concat(new[] { projectToAdd.Name }).OrderBy(name => name).ToArray();

                        var index = Array.IndexOf(names, projectToAdd.Name);

                        _projects.Insert(index, projectToAdd);
                    });
                }
            }

            var projectsToKeep   = e.Projects.Select(project => project.Id).ToArray();
            var projectsToRemove = _projects.Where(project => !projectsToKeep.Contains(project.Id)).ToArray();

            if (_projects.Any())
            {
                _application.Dispatcher.Invoke(() =>
                {
                    _projects.RemoveRange(projectsToRemove);
                });
            }

            _trie = new SuffixTrie <IProjectViewModel>(3);

            foreach (var project in _projects)
            {
                _trie.Add(project.Name.ToLowerInvariant(), project);
            }

            IsErrored = false;
            IsBusy    = false;

            NotifyOfPropertyChange(() => HasProjects);
            NotifyOfPropertyChange(() => HasNoProjects);
            NotifyOfPropertyChange(() => IsViewable);
        }