Ejemplo n.º 1
0
        /// <summary>
        /// Adds an internal element as a new aml object with a class reference to the provided container.
        /// </summary>
        /// <param name="container">The element container.</param>
        /// <param name="elementName">Name of the element.</param>
        /// <returns></returns>
        internal static InternalElementType AddObjectWithClassReference(IInternalElementContainer container, string elementName)
        {
            // check if a suitable class exists which can be used here
            // it is assumed, that the class can be found with the ID 'AMLCLASS1'
            var amlDocument = container.CAEXDocument();
            var amlClass    = amlDocument.FindByID("AMLCLASS1");

            if (amlClass == null)
            {
                // create a suitable aml class to be instantiated as an aml object.
                // we use the InternalElement with the ROOT ID as object template
                var amlObject = amlDocument.FindByID("ROOT") as InternalElementType;

                if (amlObject != null)
                {
                    amlClass      = AMLClass.AddAmlClassFromAMLObjectTemplate("AMLCLASS1", amlObject);
                    amlClass.Name = "AMLClass derived from root";
                }
            }

            if (amlClass is not SystemUnitFamilyType systemUnitClass)
            {
                return(null);
            }
            var newAmlObject = container.InternalElement.Insert(systemUnitClass.CreateClassInstance(), false);

            newAmlObject.Name = elementName;

            return(newAmlObject);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Recursively adds The InternalElement children.
 /// </summary>
 /// <param name="caexObject">The CAEX object.</param>
 /// <param name="treeNode">The tree node.</param>
 private void AddIEChilds(IInternalElementContainer caexObject, TreeNode treeNode)
 {
     foreach (var element in caexObject)
     {
         var childNode = treeNode.Nodes.Add(element.Node.Name.LocalName + ": " + element.Name);
         AddIEChilds(element, childNode);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds an internal element as a new aml object without a class reference to the provided container.
        /// </summary>
        /// <param name="container">The element container.</param>
        /// <param name="elementName">Name of the element.</param>
        /// <returns></returns>
        internal static InternalElementType AddObjectWithoutClassReference(IInternalElementContainer container, string elementName)
        {
            return(container.InternalElement.Append(elementName));

            // alternative ways providing some attribute values:
            // container.InternalElement.Append(("Name", elementName));
            // container.InternalElement.Append(("ID","ROOT"),("Name", elementName));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Adds internal element children to the provided container.
        /// InternalElement containers are InternalElements and InstanceHierarchies.
        /// </summary>
        /// <param name="container">The container.</param>
        internal static void AddElementChildren(IInternalElementContainer container, ref int levels)
        {
            // add a single child
            var newElement = AMLObject.AddObjectWithoutClassReference(container, "Child_1");

            if (levels > 0)
            {
                // add some grand childs, if last level not reached
                levels--;
                AddElementChildren(newElement, ref levels);
            }

            // add a child using an alternative method
            AMLObject.AddObjectWithClassReference(container, "Child_2");
        }