Sure it does.
You can do a foreach on a EA.Collection.
To complete my code example here's the createEAWrappers operation
/// <summary>
/// creates a list of EAwrappers who wrap the objects in the given collection
/// </summary>
/// <param name="model">the model where elements are located</param>
/// <param name="wrappedItems">the collection of items to be wrapped</param>
/// <returns>list of EAWrappers</returns>
public static List<object> createEAWrappers(EAModel model,EA.Collection wrappedItems)
{
List<object> returnList = new List<object>();
//loop the returned ea collection
foreach (object item in wrappedItems)
{
object eaWrapper = createEAWrapper(model, item);
// only add the wrappers that are not null
if (eaWrapper != null)
{
returnList.Add(eaWrapper);
}
}
return returnList;
}
And here's part of the the code that actually creates the wrapper based on the EA object "item"
/// <summary>
/// create an EAWrapper object from the given object from the EA API
/// </summary>
/// <param name="model">The model that where the object is located</param>
/// <param name="wrappedItem">the object from the EA API to be wrapped</param>
/// <returns>an EAWrapper that wraps the given wrappedItem</returns>
public static object createEAWrapper(EAModel model, object wrappedItem)
{
object eaWrapper = null;
if (wrappedItem is EA.Element)
{
EA.Element element = wrappedItem as EA.Element;
//object is an element, figure out wich element this is
if (element.Type == "Class")
{
if (element.StereotypeEx.Contains("enumeration"))
{
//create new EA enumeration
eaWrapper = new EAEnumeration(model,element);
}else
{
// create new EAclass
eaWrapper = new EAClass(model, element);
}
}
else if (element.Type == "Activity")
{
//create new activity
eaWrapper = new EAActivity(model, element);
}
else if (element.Type == "Package")
{
//create new package
eaWrapper = new EAPackage(model, element);
}
else if (element.Type == "GUIElement")
{
eaWrapper = new EAScreenElement(model, element);
}
else if (element.Type == "Screen")
{
eaWrapper = new EAScreen(model, element);
}
else if (element.Type == "Action")
{
eaWrapper = new EAAction(model, element);
}
else if (element.Type == "Collaboration")
{
eaWrapper = new EACollaboration(model, element);
}
else if (element.Type == "Interface")
{
eaWrapper = new EAInterface(model, element);
}
else if (element.Type == "State")
{
eaWrapper = new EAState(model, element);
}
else if (element.Type == "UseCase")
{
eaWrapper = new EAUseCase(model, element);
}
else if (element.Type == "InformationItem")
{
eaWrapper = new EAInformationItem(model, element);
}
else
{
// TODO: add other types when needed
eaWrapper = new EAElement(model, element);
//throw new Exception("element of type " + element.Type + " cannot be wrapped in an EAElement");
}
}
else if (wrappedItem is EA.Attribute)
Geert