void InitMembers(CecilLoader loader) { this.AddDefaultConstructorIfRequired = (this.ClassType == ClassType.Struct || this.ClassType == ClassType.Enum); if (typeDefinition.HasMethods) { foreach (MethodDefinition method in typeDefinition.Methods) { if (loader.IsVisible(method.Attributes)) { EntityType type = EntityType.Method; if (method.IsSpecialName) { if (method.IsConstructor) type = EntityType.Constructor; else if (method.Name.StartsWith("op_", StringComparison.Ordinal)) type = EntityType.Operator; else continue; } this.Methods.Add(loader.ReadMethod(method, this, type)); } } } if (typeDefinition.HasFields) { foreach (FieldDefinition field in typeDefinition.Fields) { if (loader.IsVisible(field.Attributes) && !field.IsSpecialName) { this.Fields.Add(loader.ReadField(field, this)); } } } if (typeDefinition.HasProperties) { string defaultMemberName = null; var defaultMemberAttribute = typeDefinition.CustomAttributes.FirstOrDefault( a => a.AttributeType.FullName == typeof(System.Reflection.DefaultMemberAttribute).FullName); if (defaultMemberAttribute != null && defaultMemberAttribute.ConstructorArguments.Count == 1) { defaultMemberName = defaultMemberAttribute.ConstructorArguments[0].Value as string; } foreach (PropertyDefinition property in typeDefinition.Properties) { bool getterVisible = property.GetMethod != null && loader.IsVisible(property.GetMethod.Attributes); bool setterVisible = property.SetMethod != null && loader.IsVisible(property.SetMethod.Attributes); if (getterVisible || setterVisible) { EntityType type = property.Name == defaultMemberName ? EntityType.Indexer : EntityType.Property; this.Properties.Add(loader.ReadProperty(property, this, type)); } } } if (typeDefinition.HasEvents) { foreach (EventDefinition ev in typeDefinition.Events) { if (ev.AddMethod != null && loader.IsVisible(ev.AddMethod.Attributes)) { this.Events.Add(loader.ReadEvent(ev, this)); } } } }