Ejemplo n.º 1
0
        static TypeToAssemblyNamespaceMap ScanProjectTypes(List<ProjectElement> projectsToGetTypes)
        {
            TypeToAssemblyNamespaceMap result = new TypeToAssemblyNamespaceMap();
            if (projectsToGetTypes == null)
                return result;

            foreach (ProjectElement projectToGetTypes in projectsToGetTypes)
            {
                ITypeElement[] projectTypes = GetTypesDeclaredInProject(projectToGetTypes);
                if (projectTypes == null)
                    continue;

                foreach (ITypeElement typeElement in projectTypes)
                {
                    if (typeElement == null)
                        continue;

                    if (typeElement.ParentNamespace == null)
                        continue;

                    string typeNamespace = typeElement.ParentNamespace.FullName;
                    if (String.IsNullOrEmpty(typeNamespace))
                        continue;

                    AssemblyNamespaceList namespaceList;
                    if (!result.TryGetValue(typeElement.Name, out namespaceList))
                    {
                        namespaceList = new AssemblyNamespaceList();
                        result.Add(typeElement.Name, namespaceList);
                    }

                    AssemblyNamespace nameSpace = new AssemblyNamespace();
                    nameSpace.ReferenceProject = projectToGetTypes;
                    nameSpace.Namespace = typeNamespace;
                    namespaceList.Add(nameSpace);
                }
            }
            return result;
        }
Ejemplo n.º 2
0
        static TypeToAssemblyNamespaceMap ScanAssemblyReferenceTypes(List<AssemblyReference> assemblyReferences)
        {
            TypeToAssemblyNamespaceMap result = new TypeToAssemblyNamespaceMap();
            if (assemblyReferences == null)
                return result;

            foreach (AssemblyReference assemblyReference in assemblyReferences)
            {
                ITypeElement[] types = GetTypesDeclaredInAssembly(assemblyReference);
                if (types == null)
                    continue;

                foreach (ITypeElement typeElement in types)
                {
                    if (typeElement == null)
                        continue;

                    if (typeElement.ParentNamespace == null)
                        continue;

                    string typeNamespace = typeElement.ParentNamespace.FullName;
                    if (String.IsNullOrEmpty(typeNamespace))
                        continue;

                    AssemblyNamespaceList namespaceList;
                    if (!result.TryGetValue(typeElement.Name, out namespaceList))
                    {
                        namespaceList = new AssemblyNamespaceList();
                        result.Add(typeElement.Name, namespaceList);
                    }

                    AssemblyNamespace nameSpace = new AssemblyNamespace();
                    nameSpace.AssemblyFilePath = assemblyReference.FilePath;
                    nameSpace.Namespace = typeNamespace;
                    namespaceList.Add(nameSpace);
                }
            }
            return result;
        }