/// <summary> /// Returns the export T of the startup projects if those projects support the specified capabilities /// </summary> public ImmutableArray <T> GetExportFromDotNetStartupProjects <T>(string capabilityMatch) where T : class { if (_dte.Value.Solution.SolutionBuild.StartupProjects is Array { Length : > 0 } startupProjects) { var results = PooledArray <T> .GetInstance(); foreach (string projectName in startupProjects) { _solution.Value.GetProjectOfUniqueName(projectName, out IVsHierarchy hier); if (hier?.IsCapabilityMatch(capabilityMatch) == true) { string?projectPath = hier.GetProjectFilePath(); if (projectPath != null) { T?export = _projectExportProvider.GetExport <T>(projectPath); if (export != null) { results.Add(export); } } } } return(results.ToImmutableAndFree()); } return(ImmutableArray <T> .Empty); }
public IDependenciesSnapshot?GetSnapshot(string projectFilePath) { Requires.NotNullOrEmpty(projectFilePath, nameof(projectFilePath)); lock (_snapshotProviders) { if (!_snapshotProviders.TryGetValue(projectFilePath, out IDependenciesSnapshotProvider snapshotProvider)) { snapshotProvider = _projectExportProvider.GetExport <IDependenciesSnapshotProvider>(projectFilePath); if (snapshotProvider != null) { RegisterSnapshotProvider(snapshotProvider); } } return(snapshotProvider?.CurrentSnapshot); } }
/// <summary> /// Returns the export T of the startup projects if those projects support the specified capabilities /// </summary> public ImmutableArray <T> GetExportFromDotNetStartupProjects <T>(string capabilityMatch) where T : class { DTE?dte = _dte.Value; Assumes.Present(dte); if (dte.Solution.SolutionBuild.StartupProjects is Array startupProjects && startupProjects.Length > 0) { IVsSolution?solution = _solution.Value; Assumes.Present(solution); var results = PooledArray <T> .GetInstance(); foreach (string projectName in startupProjects) { solution.GetProjectOfUniqueName(projectName, out IVsHierarchy hier); if (hier != null && hier.IsCapabilityMatch(capabilityMatch)) { string?projectPath = hier.GetProjectFilePath(); if (projectPath != null) { T?export = _projectExportProvider.GetExport <T>(projectPath); if (export != null) { results.Add(export); } } } } return(results.ToImmutableAndFree()); } return(ImmutableArray <T> .Empty); }
public IDependenciesSnapshotProvider GetSnapshotProvider(string projectFilePath) { if (string.IsNullOrEmpty(projectFilePath)) { throw new ArgumentException(nameof(projectFilePath)); } lock (_snapshotProviders) { if (_snapshotProviders.TryGetValue(projectFilePath, out IDependenciesSnapshotProvider snapshotProvider)) { return(snapshotProvider); } snapshotProvider = _projectExportProvider.GetExport <IDependenciesSnapshotProvider>(projectFilePath); if (snapshotProvider != null) { RegisterSnapshotProvider(snapshotProvider); } return(snapshotProvider); } }
/// <summary> /// Get the unconfigured property provider for the project /// </summary> internal virtual UnconfiguredProject GetUnconfiguredProject(IVsHierarchy hier) { IProjectExportProvider provider = GetExport <IProjectExportProvider>(hier); return(provider.GetExport <UnconfiguredProject>(hier.GetDTEProject().FileName)); }