Book a Demo

Author Topic: How to sort a EA.Collection?  (Read 5249 times)

Stephanie

  • EA User
  • **
  • Posts: 40
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
How to sort a EA.Collection?
« on: May 24, 2007, 03:37:40 am »
Hi,

I have to do some kind of sorting/rearranging for an EA.Collection.

Background: When I interate through the subelelements of a structured activity (Action, Decisions, Initial Nodes,...), the InitialNode should always be processed first, so I thought of reordering the collection of subeleemnts so that the initial node is on first position.

However, the methods that an EA.Colllection provides are not suffient for this task (in my opinion).

What's the best way to do this?

jkorman

  • EA User
  • **
  • Posts: 99
  • Karma: +0/-0
    • View Profile
Re: How to sort a EA.Collection?
« Reply #1 on: May 24, 2007, 04:43:09 am »
Two things come to mind.....

You'll probably have to copy the EA.Collection "elements" into a sortable collection.

The "elements" of an EA.Collection do not have comparison semantics, so you'll have to write some sort of adapter for each "element type" that you wish to compare.

Jim

thomaskilian

  • Guest
Re: How to sort a EA.Collection?
« Reply #2 on: May 24, 2007, 06:09:21 am »
That's right. I usualy write my own classes for that which <<extend>> the EA classes.

Stephanie

  • EA User
  • **
  • Posts: 40
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: How to sort a EA.Collection?
« Reply #3 on: May 24, 2007, 06:32:41 am »
Let's focus on the first option, do I have to copy each item of the collection "one by one"?

I hoped that I could use a suitable Dot Net Collection class and call its constructor with the EA.Collecton as parameter.

Any ideas which .Net interface the EA.Collection implements?

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: How to sort a EA.Collection?
« Reply #4 on: May 24, 2007, 06:35:13 am »
None, it is a COM object without a default property.

However, .Net will try to wrap the collection if you use the Interop file. You can use For Each syntax, or get an IEnumerator.

David
No, you can't have it!