Ejemplo n.º 1
0
        private void AddTypesFromAssembly(Assembly assembly,
                                          SortedDictionary <string, List <TypeInformation> > typeList)
        {
            try
            {
                foreach (var type in
                         from assemblyType in assembly.GetTypes()
                         where (assemblyType.IsPublic &&
                                !assemblyType.IsCOMObject)
                         select assemblyType)
                {
                    List <TypeInformation> typesInNamespace = null;
                    var typeNamespace = type.Namespace ?? string.Empty;

                    if (!typeList.ContainsKey(typeNamespace))
                    {
                        typesInNamespace = new List <TypeInformation>();
                        typeList.Add(typeNamespace, typesInNamespace);
                    }
                    else
                    {
                        typesInNamespace = typeList[typeNamespace];
                    }

                    var typeInformation = new TypeInformation(type.Name, assembly.FullName);

                    foreach (var method in type.GetMethods(
                                 BindingFlags.Public | BindingFlags.Instance |
                                 BindingFlags.Static | BindingFlags.DeclaredOnly))
                    {
                        try
                        {
                            typeInformation.Add(method.ToString());
                        }
                        catch (BadImageFormatException) { }
                    }

                    typesInNamespace.Add(typeInformation);
                }
            }
            catch (ReflectionTypeLoadException) { }
        }