public void Update(IProject project, SpecflowSettings settings) { var lifetime = project.GetSolution().GetLifetime(); if (!_projectsInSolutionRepository.TryGetValue(lifetime, out var projectsWithSettings)) { projectsWithSettings = new HashSet <IProject>(); var addedProjects = _projectsInSolutionRepository.GetOrAdd(lifetime, projectsWithSettings); if (addedProjects == projectsWithSettings) { lifetime.OnTermination(() => { if (!_projectsInSolutionRepository.TryRemove(lifetime, out var projectsToRemove)) { return; } foreach (var projectToRemove in projectsToRemove) { _settingsRepository.TryRemove(projectToRemove, out _); } }); } } lock (projectsWithSettings) projectsWithSettings.Add(project); _settingsRepository[project] = settings; }
public SpecflowSettings GetDefaultSettings() { var settings = _settingsRepository.FirstOrDefault().Value; if (settings == null) { settings = new SpecflowSettings(); } return(settings); }