コード例 #1
0
        // Member management
        //==================

        public void Add(FormDescSubmodelElement subDescription)
        {
            if (value == null)
            {
                value = new FormDescListOfElement();
            }
            value.Add(subDescription);
        }
コード例 #2
0
 public FormDescListOfElement(FormDescListOfElement other)
 {
     if (other == null)
     {
         return;
     }
     foreach (var o in other)
     {
         this.Add(o);
     }
 }
コード例 #3
0
        // Dynamic behaviour
        //==================

        public void Add(FormDescSubmodelElement elem)
        {
            if (elem == null)
            {
                return;
            }
            if (SubmodelElements == null)
            {
                SubmodelElements = new FormDescListOfElement();
            }
            SubmodelElements.Add(elem);
        }
コード例 #4
0
 public FormDescSubmodel(FormDescSubmodel other)
     : base(other)
 {
     // this part == static, therefore only shallow copy
     this.SubmodelElements = other.SubmodelElements;
 }
コード例 #5
0
        private static void RecurseExportAsTemplate(
            AdminShell.SubmodelElementWrapperCollection smwc, FormDescListOfElement tels,
            AdminShell.AdministrationShellEnv env = null, AdminShell.ListOfConceptDescriptions cds = null)
        {
            // access
            if (smwc == null || tels == null)
            {
                return;
            }

            // over all elems
            foreach (var smw in smwc)
            {
                if (smw != null && smw.submodelElement != null)
                {
                    FormDescSubmodelElement tsme = null;
                    if (smw.submodelElement is AdminShell.Property p)
                    {
                        tsme = new FormDescProperty(
                            "" + p.idShort, FormMultiplicity.One, p.semanticId?.GetAsExactlyOneKey(),
                            "" + p.idShort, valueType: p.valueType);
                    }
                    if (smw.submodelElement is AdminShell.MultiLanguageProperty mlp)
                    {
                        tsme = new FormDescMultiLangProp(
                            "" + mlp.idShort, FormMultiplicity.One, mlp.semanticId?.GetAsExactlyOneKey(),
                            "" + mlp.idShort);
                    }
                    if (smw.submodelElement is AdminShell.File fl)
                    {
                        tsme = new FormDescFile(
                            "" + fl.idShort, FormMultiplicity.One, fl.semanticId?.GetAsExactlyOneKey(),
                            "" + fl.idShort);
                    }
                    if (smw.submodelElement is AdminShell.ReferenceElement rf)
                    {
                        tsme = new FormDescReferenceElement(
                            "" + rf.idShort, FormMultiplicity.One, rf.semanticId?.GetAsExactlyOneKey(),
                            "" + rf.idShort);
                    }
                    if (smw.submodelElement is AdminShell.SubmodelElementCollection smec)
                    {
                        tsme = new FormDescSubmodelElementCollection(
                            "" + smec.idShort, FormMultiplicity.One, smec.semanticId?.GetAsExactlyOneKey(),
                            "" + smec.idShort);
                    }

                    if (tsme != null)
                    {
                        // take over directly
                        tsme.PresetCategory = smw.submodelElement.category;

                        // Qualifers
                        var qs = smw.submodelElement.qualifiers;

                        var q = qs?.FindType("FormTitle");
                        if (q != null)
                        {
                            tsme.FormTitle = "" + q.value;
                        }

                        q = qs?.FindType("FormInfo");
                        if (q != null)
                        {
                            tsme.FormInfo = "" + q.value;
                        }

                        q = qs?.FindType("EditIdShort");
                        if (q != null)
                        {
                            tsme.FormEditIdShort = q.value.Trim().ToLower() == "true";
                        }

                        q = qs?.FindType("EditDescription");
                        if (q != null)
                        {
                            tsme.FormEditDescription = q.value.Trim().ToLower() == "true";
                        }

                        q = qs?.FindType("Multiplicity");
                        if (q != null)
                        {
                            foreach (var m in (FormMultiplicity[])Enum.GetValues(typeof(FormMultiplicity)))
                            {
                                if (("" + q.value) == Enum.GetName(typeof(FormMultiplicity), m))
                                {
                                    tsme.Multiplicity = m;
                                }
                            }
                        }

                        q = qs?.FindType("PresetValue");
                        if (q != null && tsme is FormDescProperty)
                        {
                            (tsme as FormDescProperty).presetValue = "" + q.value;
                        }

                        q = qs?.FindType("PresetMimeType");
                        if (q != null && tsme is FormDescFile)
                        {
                            (tsme as FormDescFile).presetMimeType = "" + q.value;
                        }

                        q = qs?.FindType("FormChoices");
                        if (q != null && q.value.HasContent() && tsme is FormDescProperty fdprop)
                        {
                            var choices = q.value.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                            if (choices != null && choices.Length > 0)
                            {
                                fdprop.comboBoxChoices = choices;
                            }
                        }

                        // adopt presetIdShort
                        if (tsme.Multiplicity == FormMultiplicity.ZeroToMany ||
                            tsme.Multiplicity == FormMultiplicity.OneToMany)
                        {
                            tsme.PresetIdShort += "{0:00}";
                        }

                        // Ignore this element
                        q = qs?.FindType("FormIgnore");
                        if (q != null)
                        {
                            continue;
                        }
                    }

                    if (tsme != null)
                    {
                        tels.Add(tsme);
                    }

                    // in any case, check for CD
                    if (env != null && cds != null && smw?.submodelElement?.semanticId?.Keys != null)
                    {
                        var masterCd = env.FindConceptDescription(smw?.submodelElement?.semanticId?.Keys);
                        if (masterCd != null && masterCd.identification != null)
                        {
                            // already in cds?
                            var copyCd = cds.Find(masterCd.identification);
                            if (copyCd == null)
                            {
                                // add clone
                                cds.Add(new AdminShell.ConceptDescription(masterCd));
                            }
                        }
                    }

                    // recurse
                    if (smw.submodelElement is AdminShell.SubmodelElementCollection)
                    {
                        RecurseExportAsTemplate(
                            (smw.submodelElement as AdminShell.SubmodelElementCollection).value,
                            (tsme as FormDescSubmodelElementCollection).value, env, cds);
                    }
                }
            }
        }