Example #1
0
        //
        // Helper functions
        //

        protected void DispDeleteCopyPasteItem(CopyPasteItemSME item)
        {
            // access
            if (item == null)
            {
                return;
            }

            // differentiate
            if (item.parentContainer is AdminShell.Submodel pcsm && item.wrapper != null)
            {
                this.DeleteElementInList <AdminShell.SubmodelElementWrapper>(
                    pcsm.submodelElements, item.wrapper, null);
            }

            if (item.parentContainer is AdminShell.SubmodelElementCollection pcsmc &&
                item.wrapper != null)
            {
                this.DeleteElementInList <AdminShell.SubmodelElementWrapper>(
                    pcsmc.value, item.wrapper, null);
            }

            if (item.parentContainer is AdminShell.Operation pcop && item.wrapper != null)
            {
                var placement = pcop.GetChildrenPlacement(item.sme) as
                                AdminShell.Operation.EnumerationPlacmentOperationVariable;
                if (placement != null)
                {
                    pcop[placement.Direction].Remove(placement.OperationVariable);
                }
            }
        }
Example #2
0
            // Factory

            public static CopyPasteItemBase FactoryConvertFrom(AdminShell.Referable rf)
            {
                // try fake a copy paste item (order matters!)
                CopyPasteItemBase res = CopyPasteItemSME.ConvertFrom(rf);

                if (res == null)
                {
                    res = CopyPasteItemSubmodel.ConvertFrom(rf);
                }
                if (res == null)
                {
                    res = CopyPasteItemIdentifiable.ConvertFrom(rf);
                }

                // ok
                return(res);
            }