Bump. Would you consider adding this change in v2.6?
This is a very handy helper! Particularily if you could provide an overload like:
Code:
public Dictionary<Type, IEntityCollection2> ProduceCollectionsPerTypeFromGraph(IEntityCollection2[] collectionList)
{
Dictionary<Type, IEntityCollection2> toReturn = new Dictionary<Type, IEntityCollection2>();
Dictionary<Guid, Dictionary<Guid, IEntity2>> adjacencyLists = new Dictionary<Guid, Dictionary<Guid, IEntity2>>();
Dictionary<Guid, IEntity2> recursed = new Dictionary<Guid, IEntity2>();
foreach( IEntityCollection2 collection in collectionList )
{
foreach (IEntity2 entity in collection)
{
if (!recursed.ContainsKey(entity.ObjectID))
{
ProduceAdjacencyLists(entity, adjacencyLists, recursed);
}
}
}
// recursed contains all entities in the graph. Walk it and per type, create a new entity collectionList, nongeneric.
foreach (KeyValuePair<Guid, IEntity2> pair in recursed)
{
IEntityCollection2 newCollection = null;
if (!toReturn.TryGetValue(pair.Value.GetType(), out newCollection))
{
newCollection = new EntityCollectionNonGeneric(pair.Value.GetEntityFactory());
toReturn.Add(pair.Value.GetType(), newCollection);
}
newCollection.Add(pair.Value);
}
return toReturn;
}
The reason this overload would be good is that it allows merging from multiple collections.