void ParseComponents() { foreach (var handle in metaReader.TypeDefinitions) { var typeDef = metaReader.GetTypeDefinition (handle); var baseTypeHandle = typeDef.BaseType; if (baseTypeHandle.Kind == HandleKind.TypeReference) { var typeRef = metaReader.GetTypeReference ((TypeReferenceHandle)baseTypeHandle); var name = metaReader.GetString (typeRef.Name); if (name != "CSComponent") continue; var inspector = new CSComponentInspector (typeDef, peFile, metaReader); var icomponent = inspector.Inspect (); if (icomponent != null) InspectorComponents [icomponent.Name] = icomponent; } } }
void ParseComponents() { foreach (var handle in metaReader.TypeDefinitions) { var typeDef = metaReader.GetTypeDefinition(handle); // Is this a generic type? var genericParams = typeDef.GetGenericParameters(); if (genericParams.Count != 0) continue; var typeName = metaReader.GetString(typeDef.Name); var baseTypeHandle = typeDef.BaseType; // Work up to base reference (ie defined outside this assembly) while (baseTypeHandle.Kind == HandleKind.TypeDefinition) { var baseTypeDef = metaReader.GetTypeDefinition((TypeDefinitionHandle)baseTypeHandle); // No way to predetermine if .BaseType is valid try { baseTypeHandle = baseTypeDef.BaseType; } catch (Exception) { break; } } if (baseTypeHandle.Kind == HandleKind.TypeReference) { var typeRef = metaReader.GetTypeReference((TypeReferenceHandle)baseTypeHandle); var baseName = metaReader.GetString(typeRef.Name); if (baseName != "CSComponent") continue; var inspector = new CSComponentInspector(typeDef, peFile, metaReader); var icomponent = inspector.Inspect(); if (icomponent != null) InspectorComponents[icomponent.Name] = icomponent; } } }