private AdminShell.KeyList BuildKeyListToTop(
            VisualElementGeneric visElem,
            bool includeAas = false)
        {
            // access
            if (visElem == null)
            {
                return(null);
            }

            // prepare result
            var res = new AdminShell.KeyList();
            var ve  = visElem;

            while (ve != null)
            {
                if (ve is VisualElementSubmodelRef)
                {
                    // import special case, as Submodel ref is important part of the chain!
                    var elem = ve as VisualElementSubmodelRef;
                    if (elem.theSubmodel != null)
                    {
                        res.Insert(
                            0,
                            AdminShell.Key.CreateNew(
                                elem.theSubmodel.GetElementName(), true,
                                elem.theSubmodel.identification.idType,
                                elem.theSubmodel.identification.id));
                    }

                    // include aas
                    if (includeAas && ve.Parent is VisualElementAdminShell veAas &&
                        veAas.theAas?.identification != null)
                    {
                        res.Insert(
                            0,
                            AdminShell.Key.CreateNew(
                                AdminShell.Key.AAS, true,
                                veAas.theAas.identification.idType,
                                veAas.theAas.identification.id));
                    }

                    break;
                }
                else
                if (ve.GetMainDataObject() is AdminShell.Identifiable)
                {
                    // a Identifiable will terminate the list of keys
                    var data = ve.GetMainDataObject() as AdminShell.Identifiable;
                    if (data != null)
                    {
                        res.Insert(
                            0,
                            AdminShell.Key.CreateNew(
                                data.GetElementName(), true, data.identification.idType, data.identification.id));
                    }
                    break;
                }
                else
                if (ve.GetMainDataObject() is AdminShell.Referable)
                {
                    // add a key and go up ..
                    var data = ve.GetMainDataObject() as AdminShell.Referable;
                    if (data != null)
                    {
                        res.Insert(
                            0,
                            AdminShell.Key.CreateNew(data.GetElementName(), true, "IdShort", data.idShort));
                    }
                }
                else
                // uups!
                {
                }
                // need to go up
                ve = ve.Parent;
            }

            return(res);
        }
예제 #2
0
        public AdminShell.KeyList BuildKeyListToTop(
            bool includeAas = false)
        {
            // prepare result
            var res = new AdminShell.KeyList();
            var ve  = this;

            while (ve != null)
            {
                if (ve is VisualElementSubmodelRef smr)
                {
                    // import special case, as Submodel ref is important part of the chain!
                    if (smr.theSubmodel != null)
                    {
                        res.Insert(
                            0,
                            AdminShell.Key.CreateNew(
                                smr.theSubmodel.GetElementName(), true,
                                smr.theSubmodel.identification.idType,
                                smr.theSubmodel.identification.id));
                    }

                    // include aas
                    if (includeAas && ve.Parent is VisualElementAdminShell veAas &&
                        veAas.theAas?.identification != null)
                    {
                        res.Insert(
                            0,
                            AdminShell.Key.CreateNew(
                                AdminShell.Key.AAS, true,
                                veAas.theAas.identification.idType,
                                veAas.theAas.identification.id));
                    }

                    break;
                }
                else
                if (ve.GetMainDataObject() is AdminShell.Identifiable iddata)
                {
                    // a Identifiable will terminate the list of keys
                    res.Insert(
                        0,
                        AdminShell.Key.CreateNew(
                            iddata.GetElementName(), true, iddata.identification.idType, iddata.identification.id));
                    break;
                }
                else
                if (ve.GetMainDataObject() is AdminShell.Referable rf)
                {
                    // add a key and go up ..
                    res.Insert(
                        0,
                        AdminShell.Key.CreateNew(rf.GetElementName(), true, "IdShort", rf.idShort));
                }
                else
                // uups!
                {
                }
                // need to go up
                ve = ve.Parent;
            }

            return(res);
        }