/// <summary> /// Return a list of connections that belongs to this brick or to other bricks that belong to the same /// hierarchical group than this brick. /// This function can return an empty list but not null. /// </summary> /// <param name="myTopGroup">If this brick belongs to a group, set the top group in this param, or null otherwise</param> /// <returns>A list of connection in this brick and other brick of the same group (can be empty)</returns> private List<Brick.ConnectionPoint> getConnectionsListForAllMyGroup(out Group myTopGroup) { // get all the bricks in the group of this brick myTopGroup = this.TopGroup; if (myTopGroup != null) { List<LayerItem> brickList = myTopGroup.getAllLeafItems(); // create the result list with an estimation of the number of connections List<ConnectionPoint> result = new List<ConnectionPoint>(brickList.Count * 2); // now iterate on all the bricks to get all the free connection points foreach (LayerItem item in brickList) { Brick brick = item as Brick; // iterate on the connections points to find the free ones if (brick.mConnectionPoints != null) result.AddRange(brick.mConnectionPoints); } // return the result that may be null return result; } else { if (mConnectionPoints != null) return mConnectionPoints; else return (new List<ConnectionPoint>(0)); } }