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);

                    if (metaReader.GetString(typeRef.Name) != "CSComponent")
                    {
                        continue;
                    }

                    var inspector = new CSComponentInspector(typeDef, peFile, metaReader);

                    var icomponent = inspector.Inspect();

                    if (icomponent != null)
                    {
                        InspectorComponents [icomponent.Name] = icomponent;
                    }
                }
            }
        }
Exemplo n.º 2
0
        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 parentName = 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 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;
                    }
                }
            }
        }
Exemplo n.º 3
0
            public string ToString(CSComponentInspector visualizer)
            {
                switch (this.Kind)
                {
                default:
                    return(".try");

                case HandlerKind.Catch:
                    return("catch **exceptiontype**");   // + visualizer.VisualizeLocalType(this.ExceptionType);

                case HandlerKind.Filter:
                    return("filter");

                case HandlerKind.Finally:
                    return("finally");

                case HandlerKind.Fault:
                    return("fault");
                }
            }