public override IEnumerable <IProperty> GetProperties(ITypeResolveContext context, Predicate <IProperty> filter = null) { ITypeDefinition arrayDef = systemArray.Resolve(context) as ITypeDefinition; if (arrayDef != null) { foreach (IProperty p in arrayDef.GetProperties(context, filter)) { yield return(p); } DefaultProperty indexer = new DefaultProperty(arrayDef, "Items") { EntityType = EntityType.Indexer, ReturnType = elementType, Accessibility = Accessibility.Public, Getter = DefaultAccessor.GetFromAccessibility(Accessibility.Public), Setter = DefaultAccessor.GetFromAccessibility(Accessibility.Public), IsSynthetic = true }; for (int i = 0; i < dimensions; i++) { indexer.Parameters.Add(indexerParam); } indexer.Freeze(); if (filter == null || filter(indexer)) { yield return(indexer); } } }
public override IEntity VisitEventDeclaration(EventDeclaration eventDeclaration, object data) { bool isSingleEvent = eventDeclaration.Variables.Count() == 1; Modifiers modifiers = eventDeclaration.Modifiers; DefaultEvent ev = null; foreach (VariableInitializer vi in eventDeclaration.Variables) { ev = new DefaultEvent(currentTypeDefinition, vi.Name); ev.Region = isSingleEvent ? MakeRegion(eventDeclaration) : MakeRegion(vi); ev.BodyRegion = MakeRegion(vi); ApplyModifiers(ev, modifiers); ev.ReturnType = ConvertType(eventDeclaration.ReturnType); if (eventDeclaration.Attributes.Any(a => a.AttributeTarget == "method")) { ev.AddAccessor = ev.RemoveAccessor = new DefaultAccessor { Accessibility = ev.Accessibility }; } else { // if there's no attributes on the accessors, we can re-use the shared accessor instance ev.AddAccessor = ev.RemoveAccessor = DefaultAccessor.GetFromAccessibility(ev.Accessibility); } foreach (AttributeSection section in eventDeclaration.Attributes) { if (section.AttributeTarget == "method") { // as we use the same instance for AddAccessor and RemoveAccessor, we only need to add the attribute once ConvertAttributes(ev.AddAccessor.Attributes, section); } else if (section.AttributeTarget != "field") { ConvertAttributes(ev.Attributes, section); } } currentTypeDefinition.Events.Add(ev); } return(isSingleEvent ? ev : null); }