public CodeQualitySolution(string basePath, IDirectoryHelper directoryHelper, INuGetPathHelper nuGetPathHelper, IFileHelper fileHelper, IProjectFactory projectFactory) { _directoryHelper = directoryHelper; _nuGetPathHelper = nuGetPathHelper; _fileHelper = fileHelper; if (!Path.IsPathRooted(basePath)) { throw new ArgumentOutOfRangeException(nameof(basePath), "The base path of the solution must be absolute."); } _basePath = basePath; var solutionFilePath = _directoryHelper.GetFiles(".", "*.sln", SearchOption.TopDirectoryOnly, _basePath).FirstOrDefault(); _solutionFileName = Path.GetFileName(solutionFilePath); if (HasSolutionFile) { _logger.LogInformation($"Using solution file: {_solutionFileName}"); } else { _logger.LogWarning("No solution file found."); } var projectFiles = _directoryHelper.GetFiles(".", "*.csproj", SearchOption.AllDirectories, _basePath); foreach (var projectFile in projectFiles) { _projects.Add(projectFactory.CreateProject(Path.GetFullPath(Path.Combine(_basePath, projectFile)))); } }
private Project CreateProject(IProjectFactory factory, object creationArgs) { Project project = null; if (factory.IsSingleInstance) { foreach (Project project2 in this._openProjects) { if (project2.ProjectFactory == factory) { project = project2; break; } } } if (project == null) { try { project = factory.CreateProject(creationArgs); } catch (Exception exception) { IMxUIService service = (IMxUIService) this._serviceProvider.GetService(typeof(IMxUIService)); if (service != null) { service.ReportError(exception.Message, "Unable to create a new " + factory.Name + " workspace.", false); } } if (project == null) { return project; } this._openProjects.Add(project); if ((this._myComputerProject == null) && (factory.GetType() == this._myComputerFactoryType)) { this._myComputerProject = project; } try { ProjectEventArgs e = new ProjectEventArgs(project); this.OnProjectAdded(e); } catch (Exception) { } } return project; }
public IProject GetProject(string projectId) { return(projectFactory.CreateProject(projectId, connection)); }