// Avoids reallocation of returned children ArrayList
        private void GetChildren(
            object oObj,
            ChildrenListFilter pfChildrenListFilter,
            object oChildrenListFilterCriteria,
            ObjectFilter pfObjectFilter,
            object oObjectFilterCriteria,
            EntityRelation enRelation,
            bool bRecursive,
            ICollection <object> oOutChildren)
        {
            // Get TypeInfo of specified object
            EntityTypeInfo oEntityTypeInfo =
                GetEntityTypeInfo(oObj);

            // Get the ChildrenLists according to EntityRelation filter
            EntityChildrenListInfo[] ChildrenLists = GetChildrenListsInfo(
                oEntityTypeInfo,
                enRelation);

            // Iterate ChildrenLists
            foreach (EntityChildrenListInfo oChildrenList in ChildrenLists)
            {
                // Obtain list object
                INamedObjectList oContainer = oChildrenList.GetValue(oObj) as INamedObjectList;

                if (oContainer != null)
                {
                    // Check if container passes filter
                    bool bContainerPassedFilter = (pfChildrenListFilter == null) ||
                                                  pfChildrenListFilter(oChildrenList, oChildrenListFilterCriteria);

                    object oEl;
                    for (int i = 0; i < oContainer.Count; i++)
                    {
                        oEl = oContainer[oContainer.NameByIndex(i)];

                        if (bContainerPassedFilter &&
                            (pfObjectFilter == null || pfObjectFilter(oEl, oObjectFilterCriteria)))
                        {
                            // If elements filter passed
                            oOutChildren.Add(oEl);
                        }

                        if (bRecursive)
                        {
                            // Recursive call for each children
                            GetChildren(
                                oEl,
                                pfChildrenListFilter,
                                oChildrenListFilterCriteria,
                                pfObjectFilter,
                                oObjectFilterCriteria,
                                enRelation,
                                bRecursive,
                                oOutChildren);
                        }
                    }
                }
            }
        }
Beispiel #2
0
        private void CloneChildrenTo(
            ITisDataLayerTreeNode oTargetObj,
            ICollection <ITisEntityChildInfo> ChildrenInfoCollection,
            EntityCloneSpec enEntityCloneSpec)
        {
            foreach (ITisEntityChildInfo oChildInfo in ChildrenInfoCollection)
            {
                // Get source list
                INamedObjectList oSrcList = oChildInfo.GetChildList(this);

                // Get destination list
                INamedObjectList oDstList = oChildInfo.GetChildList(oTargetObj);

                // Add cloned objects to destination list

                TisDataLayerTreeNode oChildNode;

                for (int i = 0; i < oSrcList.Count; i++)
                {
                    if (oSrcList is INamedObjectOrder)
                    {
                        oChildNode =
                            ((oSrcList as INamedObjectOrder).GetByOrder(i)) as TisDataLayerTreeNode;
                    }
                    else
                    {
                        oChildNode =
                            (oSrcList[oSrcList.NameByIndex(i)]) as TisDataLayerTreeNode;
                    }

                    // Clone
                    ITisDataLayerTreeNode oClonedChildNode =
                        oChildNode.Clone(enEntityCloneSpec);

                    // Add to list
                    oDstList.Add(oClonedChildNode);
                }
            }
        }