Пример #1
0
        private void ExportTable_EnumerateSubmodel(
            ExportTableAasEntitiesList list, AdminShell.AdministrationShellEnv env,
            bool broadSearch, int depth,
            AdminShell.Submodel sm, AdminShell.SubmodelElement sme)
        {
            // check
            if (list == null || env == null || sm == null)
            {
                return;
            }

            //
            // Submodel or SME ??
            //

            AdminShell.IEnumerateChildren coll = null;
            if (sme == null)
            {
                // yield SM
                list.Add(new ExportTableAasEntitiesItem(depth, sm: sm));

                // use collection
                coll = sm;
            }
            else
            {
                // simple check for SME collection
                if (sme is AdminShell.IEnumerateChildren)
                {
                    coll = (sme as AdminShell.IEnumerateChildren);
                }
            }

            // pass 1: process value
            if (coll != null)
            {
                foreach (var ci in coll.EnumerateChildren())
                {
                    // gather data for this entity
                    var sme2 = ci.submodelElement;
                    var cd   = env.FindConceptDescription(sme2?.semanticId?.Keys);
                    list.Add(new ExportTableAasEntitiesItem(depth, sm, sme2, cd));

                    // go directly deeper?
                    if (!broadSearch && ci.submodelElement != null &&
                        ci.submodelElement is AdminShell.IEnumerateChildren)
                    {
                        ExportTable_EnumerateSubmodel(
                            list, env, broadSearch: false, depth: 1 + depth, sm: sm, sme: ci.submodelElement);
                    }
                }
            }

            // pass 2: go for recursion AFTER?
            if (broadSearch)
            {
                if (coll != null)
                {
                    foreach (var ci in coll.EnumerateChildren())
                    {
                        if (ci.submodelElement != null && ci.submodelElement is AdminShell.IEnumerateChildren)
                        {
                            ExportTable_EnumerateSubmodel(
                                list, env, broadSearch: true, depth: 1 + depth, sm: sm, sme: ci.submodelElement);
                        }
                    }
                }
            }
        }
Пример #2
0
        private void ExportTable_EnumerateSubmodel(
            List <ExportTableAasEntitiesList> list, AdminShell.AdministrationShellEnv env,
            bool broadSearch, bool actInHierarchy, int depth,
            AdminShell.Submodel sm, AdminShell.SubmodelElement sme)
        {
            // check
            if (list == null || env == null || sm == null)
            {
                return;
            }

            //
            // Submodel or SME ??
            //

            AdminShell.IEnumerateChildren coll = null;
            if (sme == null)
            {
                // yield SM
                // MIHO 21-11-24: IMHO this makes no sense
                //// list.Add(new ExportTableAasEntitiesItem(depth, sm: sm, parentSm: sm));

                // use collection
                coll = sm;
            }
            else
            {
                // simple check for SME collection
                if (sme is AdminShell.IEnumerateChildren)
                {
                    coll = (sme as AdminShell.IEnumerateChildren);
                }
            }

            // prepare listItem
            ExportTableAasEntitiesList listItem = null;

            if (!actInHierarchy)
            {
                // add everything in one list
                if (list.Count < 1)
                {
                    list.Add(new ExportTableAasEntitiesList());
                }
                listItem = list[0];
            }
            else
            {
                // create a new list for each recursion
                listItem = new ExportTableAasEntitiesList();
                list.Add(listItem);
            }

            // pass 1: process value
            if (coll != null)
            {
                foreach (var ci in coll.EnumerateChildren())
                {
                    // gather data for this entity
                    var sme2 = ci.submodelElement;
                    var cd   = env.FindConceptDescription(sme2?.semanticId?.Keys);

                    // add
                    listItem.Add(new ExportTableAasEntitiesItem(depth, sm, sme2, cd,
                                                                parent: coll as AdminShell.Referable));

                    // go directly deeper?
                    if (!broadSearch && ci.submodelElement != null &&
                        ci.submodelElement is AdminShell.IEnumerateChildren)
                    {
                        ExportTable_EnumerateSubmodel(
                            list, env, broadSearch: false, actInHierarchy,
                            depth: 1 + depth, sm: sm, sme: ci.submodelElement);
                    }
                }
            }

            // pass 2: go for recursion AFTER?
            if (broadSearch)
            {
                if (coll != null)
                {
                    foreach (var ci in coll.EnumerateChildren())
                    {
                        if (ci.submodelElement != null && ci.submodelElement is AdminShell.IEnumerateChildren)
                        {
                            ExportTable_EnumerateSubmodel(
                                list, env, broadSearch: true, actInHierarchy,
                                depth: 1 + depth, sm: sm, sme: ci.submodelElement);
                        }
                    }
                }
            }
        }