private IEvent ReadEvent() { DefaultEvent p = new DefaultEvent(_currentClass, ReadString()); ReadMember(p); return(p); }
public override IMember Clone() { DefaultEvent de = new DefaultEvent(Name, ReturnType, Modifiers, Region, BodyRegion, DeclaringType); foreach (ExplicitInterfaceImplementation eii in InterfaceImplementations) { de.InterfaceImplementations.Add(eii.Clone()); } return(de); }
void InitMembers(TypeDefinition type) { string defaultMemberName = null; foreach (CustomAttribute att in type.CustomAttributes) { if (att.Constructor.DeclaringType.FullName == "System.Reflection.DefaultMemberAttribute" && att.ConstructorParameters.Count == 1) { defaultMemberName = att.ConstructorParameters[0] as string; } } foreach (TypeDefinition nestedType in type.NestedTypes) { TypeAttributes visibility = nestedType.Attributes & TypeAttributes.VisibilityMask; if (visibility == TypeAttributes.NestedPublic || visibility == TypeAttributes.NestedFamily || visibility == TypeAttributes.NestedFamORAssem) { string name = nestedType.Name; int pos = name.LastIndexOf('/'); if (pos > 0) { name = name.Substring(pos + 1); } if (name.Length == 0 || name[0] == '<') { continue; } if (name.Length > 2 && name[name.Length - 2] == '`') { name = name.Substring(0, name.Length - 2); } name = this.FullyQualifiedName + "." + name; InnerClasses.Add(new CecilClass(this.CompilationUnit, this, nestedType, name)); } } foreach (FieldDefinition field in type.Fields) { if (IsVisible(field.Attributes) && !field.IsSpecialName) { DefaultField f = new DefaultField(this, field.Name); f.Modifiers = TranslateModifiers(field); f.ReturnType = CreateType(this.ProjectContent, this, field.FieldType); AddAttributes(CompilationUnit.ProjectContent, f.Attributes, field.CustomAttributes); Fields.Add(f); } } foreach (PropertyDefinition property in type.Properties) { if ((property.GetMethod != null && IsVisible(property.GetMethod.Attributes)) || (property.SetMethod != null && IsVisible(property.SetMethod.Attributes))) { DefaultProperty p = new DefaultProperty(this, property.Name); if (this.ClassType == ClassType.Interface) { p.Modifiers = ModifierEnum.Public | ModifierEnum.Abstract; } else { p.Modifiers = TranslateModifiers(property); } p.ReturnType = CreateType(this.ProjectContent, this, property.PropertyType); p.CanGet = property.GetMethod != null; p.CanSet = property.SetMethod != null; if (p.Name == defaultMemberName) { p.IsIndexer = true; } AddParameters(p, property.Parameters); AddAttributes(CompilationUnit.ProjectContent, p.Attributes, property.CustomAttributes); Properties.Add(p); } } foreach (EventDefinition eventDef in type.Events) { if (eventDef.AddMethod != null && IsVisible(eventDef.AddMethod.Attributes)) { DefaultEvent e = new DefaultEvent(this, eventDef.Name); if (this.ClassType == ClassType.Interface) { e.Modifiers = ModifierEnum.Public | ModifierEnum.Abstract; } else { e.Modifiers = TranslateModifiers(eventDef); } e.ReturnType = CreateType(this.ProjectContent, this, eventDef.EventType); AddAttributes(CompilationUnit.ProjectContent, e.Attributes, eventDef.CustomAttributes); Events.Add(e); } } foreach (MethodDefinition method in type.Constructors) { AddMethod(method); } foreach (MethodDefinition method in type.Methods) { if (!method.IsSpecialName) { AddMethod(method); } } }