コード例 #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;
        }
コード例 #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;
        }
コード例 #3
0
        TypeToAssemblyNamespaceMap LoadAssemblyMap(BinaryReader reader, ExtendedFrameworkVersion frameworkVersion)
        {
            TypeToAssemblyNamespaceMap result = new TypeToAssemblyNamespaceMap();
              result._AssemblyPath = reader.ReadString();
              result._AssemblySignature = FileSignature.Read(reader);

              int typeCount = reader.ReadInt32();
              for (int typeIndex = 0; typeIndex < typeCount; typeIndex++)
              {
            string typeName = reader.ReadString();
            int namespaceCount = reader.ReadInt32();

            if (!result.ContainsKey(typeName))
              result.Add(typeName, new AssemblyNamespaceList());
            AssemblyNamespaceList assemblyNamespaces = result.GetNamespaceList(typeName);
            for (int i = 0; i < namespaceCount; i++)
            {
              int assemblyIndex = reader.ReadInt32();
              int namespaceIndex = reader.ReadInt32();
              assemblyNamespaces.Add(new AssemblyNamespace(frameworkVersion, assemblyIndex, namespaceIndex));
            }
              }
              return result;
        }
コード例 #4
0
        void SaveAssemblyMap(BinaryWriter writer, TypeToAssemblyNamespaceMap map)
        {
            writer.Write(map._AssemblyPath);
              map._AssemblySignature.Write(writer);

              writer.Write(map._CaseSensitiveData.Keys.Count);
              int typeIndex = 0;
              foreach (string typeName in map._CaseSensitiveData.Keys)
              {
            AssemblyNamespaceList assemblyNamespaces = map._CaseSensitiveData[typeName];
            writer.Write(typeName);
            writer.Write(assemblyNamespaces.Count);
            for (int i = 0; i < assemblyNamespaces.Count; i++)
            {
              AssemblyNamespace thisAssemblyNamespace = assemblyNamespaces[i];
              writer.Write(thisAssemblyNamespace.AssemblyIndex);
              writer.Write(thisAssemblyNamespace.NamespaceIndex);
            }
            typeIndex++;
              }
        }
コード例 #5
0
        TypeToAssemblyNamespaceMap CollectTypes(string assemblyPath, ExtendedFrameworkVersion frameworkVersion)
        {
            assemblyPath = assemblyPath.ToLowerInvariant();

              TypeToAssemblyNamespaceMap result = new TypeToAssemblyNamespaceMap();
              result._AssemblyPath = assemblyPath;
              result._AssemblySignature = new FileSignature(assemblyPath);

              AssemblyTypeLoadResult typeLoadResult = LoadTypesFromAssembly(assemblyPath);
              if (typeLoadResult == null)
            return result;

              foreach (ITypeInfo typeInfo in typeLoadResult.Types)
              {
            if (!result.ContainsKey(typeInfo.NestedName))
              result.Add(typeInfo.NestedName, new AssemblyNamespaceList());
            AssemblyNamespaceList list = result.GetNamespaceList(typeInfo.NestedName);
            list.AddUnique(new AssemblyNamespace(typeLoadResult.AssemblyInfo.FullName, typeInfo.Namespace, frameworkVersion));
              }
              return result;
        }