/// <summary> /// Adds all members of a class to a dictionary. /// </summary> /// <param name="class">The class to collect.</param> /// <param name="members">Adds all members of the class to the given dictionary.</param> private static void CollectClassMembersAux(ClassBase @class, Dictionary <string, List <Element> > members) { Param.AssertNotNull(@class, "class"); Param.AssertNotNull(members, "members"); for (Element child = @class.FindFirstChildElement(); child != null; child = child.FindNextSiblingElement()) { if (child.ElementType == ElementType.Field) { // Look through each of the declarators in the field. var variableDeclaration = ((Field)child).VariableDeclarationStatement; if (variableDeclaration != null) { foreach (var declarator in variableDeclaration.Declarators) { AddClassMember(members, child, declarator.Identifier.Text); } } } else if (child.ElementType == ElementType.Event) { // Look through each of the declarators in the event. foreach (EventDeclaratorExpression declarator in ((Event)child).Declarators) { AddClassMember(members, child, declarator.Identifier.Text); } } else if (child.ElementType != ElementType.EmptyElement) { AddClassMember(members, child, child.Name); } } }