Exemple #1
0
        new IEnumerable <TypeDefinition> GetDocumentationTypes(AssemblyDefinition assembly, List <string> forTypes, HashSet <string> seen)
        {
            int typeDepth = -1;

            while (ecmadocs.Read())
            {
                switch (ecmadocs.Name)
                {
                case "Type":
                {
                    if (typeDepth == -1)
                    {
                        typeDepth = ecmadocs.Depth;
                    }
                    if (ecmadocs.NodeType != XmlNodeType.Element)
                    {
                        continue;
                    }
                    if (typeDepth != ecmadocs.Depth)         // nested <TypeDefinition/> element?
                    {
                        continue;
                    }
                    string typename  = ecmadocs.GetAttribute("FullName");
                    string typename2 = MDocUpdater.GetTypeFileName(typename);
                    if (forTypes != null &&
                        forTypes.BinarySearch(typename) < 0 &&
                        typename != typename2 &&
                        forTypes.BinarySearch(typename2) < 0)
                    {
                        continue;
                    }
                    TypeDefinition t;
                    if ((t = assembly.GetType(typename)) == null &&
                        (t = assembly.GetType(typename2)) == null)
                    {
                        continue;
                    }
                    seen.Add(typename);
                    if (typename != typename2)
                    {
                        seen.Add(typename2);
                    }
                    Console.WriteLine("  Import: {0}", t.FullName);
                    if (ecmadocs.Name != "Docs")
                    {
                        int depth = ecmadocs.Depth;
                        while (ecmadocs.Read())
                        {
                            if (ecmadocs.Name == "Docs" && ecmadocs.Depth == depth + 1)
                            {
                                break;
                            }
                        }
                    }
                    if (!ecmadocs.IsStartElement("Docs"))
                    {
                        throw new InvalidOperationException("Found " + ecmadocs.Name + "; expecting <Docs/>!");
                    }
                    yield return(t);

                    break;
                }

                default:
                    break;
                }
            }
        }