private MethodInfo[] GetMethods(TypeItem typeItem)
        {
            // better way to sort.. IComparable? todo
            Dictionary <string, MethodInfo> d = new Dictionary <string, MethodInfo>();
            List <string> l = new List <string>();

            string id;

            foreach (MethodInfo mi in typeItem.TypeRef.GetMethods(
                         BindingFlags.NonPublic | BindingFlags.Public |
                         BindingFlags.Instance | BindingFlags.Static |
                         BindingFlags.DeclaredOnly))
            {
                if (mi.IsSpecialName)
                {
                    continue;
                }

                try
                {
                    id = RefHelp.GetNameWithParameterList(mi);
                }
                catch (FileNotFoundException exc)
                {
                    if (!_miWarnedAlready.Contains(typeItem.FullName))
                    {
                        _logView.LogExcStr(exc, "Failed to get methods for " + typeItem.FullName);
                        _miWarnedAlready.Add(typeItem.FullName);
                    }
                    continue;
                }

                d.Add(id, mi);
                l.Add(id);
            }
            l.Sort();

            MethodInfo[] result = new MethodInfo[l.Count];

            for (int i = 0; i < l.Count; i++)
            {
                result[i] = d[l[i]];
            }

            return(result);
        }
        // http://msdn2.microsoft.com/en-us/library/system.type.findinterfaces.aspx
        private static List <string> GetImplementedInterfaces(TypeItem typeItem)
        {
            List <string> result = new List <string>();

            try
            {
                TypeFilter myFilter     = new TypeFilter(MyInterfaceFilter);
                Type[]     myInterfaces = typeItem.TypeRef.FindInterfaces(myFilter, null);
                for (int i = 0; i < myInterfaces.Length; i++)
                {
                    result.Add(myInterfaces[i].ToString());
                }
            }
            catch (ArgumentNullException)
            {
                //Console.WriteLine("ArgumentNullException: " + e.Message);
            }
            catch (TargetInvocationException)
            {
                //Console.WriteLine("TargetInvocationException: " + e.Message);
            }

            return(result);
        }
        private void ReflectAssembly(AssemblyItem assemblyItem, Assembly asm, bool invert)
        {
            string        ns;
            NamespaceItem nsItem;
            Dictionary <string, NamespaceItem> nsItems = new Dictionary <string, NamespaceItem>();

            // Add the assembly item itself to the lookup.
            _projectBrowser.AddLookup(assemblyItem, assemblyItem.GetID(), invert);

            try
            {
                Type[] types = asm.GetTypes();
            }
            catch (ReflectionTypeLoadException exc)
            {
                _logView.LogExcStr(exc, "Failed to call GetTypes on " + asm.FullName);
                return;
            }

            foreach (Type t in asm.GetTypes())
            {
                ns = t.Namespace;
                if (string.IsNullOrEmpty(ns))
                {
                    ns = "(none)";
                }

                if (!nsItems.ContainsKey(ns))
                {
                    nsItem = new NamespaceItem(ns, assemblyItem);
                    nsItems.Add(ns, nsItem);
                    assemblyItem.NameSpaces.Add(nsItem);
                    _projectBrowser.AddLookup(nsItem, nsItem.GetID(), invert);
                }
                else
                {
                    nsItem = nsItems[ns];
                }

                // Flatten nested types.
                string name = t.Name;
                if (t.IsNested)
                {
                    // Flat with .id'd name.
                    Type parentType = t.DeclaringType;
                    while (parentType != null)
                    {
                        name       = parentType.Name + "." + name;
                        parentType = parentType.DeclaringType;
                    }
                }

                try
                {
                    TypeItem typeItem = new TypeItem(name, t.FullName, t, nsItem);

                    nsItem.Types.Add(typeItem);
                    _projectBrowser.AddLookup(typeItem, typeItem.GetID(), invert);

                    foreach (MethodInfo mi in GetMethods(typeItem))
                    {
                        MethodItem methodItem = new MethodItem(mi.Name, mi, typeItem);
                        typeItem.Methods.Add(methodItem);

                        _projectBrowser.AddLookup(methodItem, methodItem.GetID(), invert);
                    }

                    // Get the list of implemented interfaces.
                    typeItem.Implements = GetImplementedInterfaces(typeItem);

                    if (typeItem.TypeRef.BaseType != null)
                    {
                        typeItem.InheritsFrom = typeItem.TypeRef.BaseType.ToString();
                    }
                    else
                    {
                        typeItem.InheritsFrom = null;
                    }
                }
                catch (Exception exc)
                {
                    _logView.LogExcStr(exc, "Generic Types issue?");
                }
            }
        }