Problem
All elements of an subelement should be catched
Approach – Solution
Recursively iterate through all subelements and AddRange (already a list) to the List.
The interuption of the recursion is, when an empty List is used as parameter for AddRange, because the loop will not be called where the AddRange-Method is in on next iteration.
Solution – Approach
private List<EA.Element> getElementsOfElement(EA.Element actualElement)
{
List<EA.Element> elementsOfElement = new List<EA.Element>();
EA.Collection elements;
elements = actualElement.Elements;
foreach (EA.Element element in elements)
{
elementsOfElement.Add(element);
elementsOfElement.AddRange(getElementsOfElement(element));
}
return elementsOfElement;
}