Ejemplo n.º 1
0
 /// <summary>
 /// Get the information for an assembly.
 /// </summary>
 /// <param name="reader">The metadata reader.</param>
 /// <returns>The assembly's information.</returns>
 public static AssemblyInfo GetAssemblyInfo(this MetadataReader reader)
 {
     return(new AssemblyInfo
     {
         Types = reader.GetCollection(reader.TypeDefinitions, GetTypeInfo)
     });
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Get the information for a type.
        /// </summary>
        /// <param name="reader">The metadata reader.</param>
        /// <param name="handle">The type definition to read.</param>
        /// <returns>The type's information.</returns>
        public static TypeInfo GetTypeInfo(this MetadataReader reader, TypeDefinitionHandle handle)
        {
            var typeDefinition = reader.GetTypeDefinition(handle);

            var fieldDefinitions    = typeDefinition.GetFields();
            var methodDefinitions   = typeDefinition.GetMethods();
            var propertyDefinitions = typeDefinition.GetProperties();

            return(new TypeInfo
            {
                Name = reader.GetString(typeDefinition.Name),
                Namespace = reader.GetString(typeDefinition.Namespace),

                Attributes = typeDefinition.Attributes,

                Fields = reader.GetCollection(fieldDefinitions, GetFieldInfo),
                Methods = reader.GetCollection(methodDefinitions, GetMethodInfo),
                Properties = reader.GetCollection(propertyDefinitions, GetPropertyInfo),
            });
        }