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); de.CopyDocumentationFrom(this); foreach (ExplicitInterfaceImplementation eii in InterfaceImplementations) { de.InterfaceImplementations.Add(eii.Clone()); } if (addMethod != null) { de.addMethod = (IMethod)addMethod.Clone(); } if (removeMethod != null) { de.removeMethod = (IMethod)removeMethod.Clone(); } if (raiseMethod != null) { de.raiseMethod = (IMethod)raiseMethod.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.ConstructorArguments.Count == 1) { defaultMemberName = att.ConstructorArguments[0].Value 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; } name = ReflectionClass.SplitTypeParameterCountFromReflectionName(name); 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, field); AddAttributes(CompilationUnit.ProjectContent, f, f.Attributes, field); Fields.Add(f); } } foreach (PropertyDefinition property in type.Properties) { AddProperty(defaultMemberName, property); } 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, eventDef); AddAttributes(CompilationUnit.ProjectContent, e, e.Attributes, eventDef); Events.Add(e); } } this.AddDefaultConstructorIfRequired = (this.ClassType == ClassType.Struct || this.ClassType == ClassType.Enum); foreach (MethodDefinition method in type.Methods) { if (method.IsConstructor || !method.IsSpecialName) { AddMethod(method); } } }