Exemple #1
0
 /// <summary>
 /// This constuctor is called to construct any ModelElement.
 /// </summary>
 /// <param name="parent">A reference to the parent model element.</param>
 /// <param name="name">The name of the model element.</param>
 public ModelElementBase(ModelElementBase parent, string name)
 {
     ConstructorCalls(name);
     Parent = parent ?? throw new ArgumentNullException($"Tried to construct ModelElement with name \"{name}\" but the parent ModelElement is null.");
     parent.AddModelElement(this);
     MyModel = parent.MyModel;
 }
Exemple #2
0
        /// <summary>
        /// Changes the parent model element of this model element to the supplied model element.
        /// </summary>
        /// <param name="newParent">The parent for this model element.</param>
        private void ChangeParentModelElement(ModelElementBase newParent)
        {
            ModelElementBase oldParent = Parent;

            if (oldParent != newParent)
            {
                oldParent.RemoveModelElement(this);
                newParent.AddModelElement(this);
                MyModel = newParent.MyModel;
            }
        }