Exemplo n.º 1
0
        /// <summary>
        /// Iterates the types in the project
        /// </summary>
        /// <param name="visitor">The visitor for the iterator</param>
        public void IterateTypes(TypeVisitor visitor)
        {
            _visitor = visitor;
            Solution sol = _workspace.CurrentSolution;
            ProjectDependencyGraph graph = sol.GetProjectDependencyGraph();

            // Typescript projects show up with the same project path, so make sure it supports compilation
            Project mainProj = sol.Projects.Where(proj => proj.Id.Equals(_projectId) && proj.SupportsCompilation).FirstOrDefault();

            if (mainProj == null)
            {
                throw new InvalidOperationException($"Project with path {_projectId} does not exist.");
            }

            // Get a list of all classes being extracted
            Dictionary <string, Compilation> compilations = new Dictionary <string, Compilation>();

            AddCompiledProjects(sol, new List <ProjectId> {
                mainProj.Id
            }, compilations);
            AddCompiledProjects(sol, graph.GetProjectsThatThisProjectDirectlyDependsOn(mainProj.Id), compilations);
            AddCompiledProjects(sol, graph.GetProjectsThatThisProjectTransitivelyDependsOn(mainProj.Id), compilations);

            foreach (Compilation comp in compilations.Values)
            {
                CompilationParser parser = new CompilationParser(comp, _options);
                parser.IterateTypes(_visitor);
            }
        }