예제 #1
0
        public virtual S hasTargetElement(ModelElementInstance instance, ModelElementInstance targetElement)
        {
            NotNull;

            ModelElementInstance actualTargetElement = actual.getReferenceTargetElement(instance);

            if (!targetElement.Equals(actualTargetElement))
            {
                failWithMessage("Expected reference <%s> to have target element <%s> but was <%s>", actual, targetElement, actualTargetElement);
            }

            return(myself);
        }
예제 #2
0
        /// <summary>
        /// Set the reference target model element instance
        /// </summary>
        /// <param name="referenceSourceElement"> the reference source model element instance </param>
        /// <param name="referenceTargetElement"> the reference target model element instance </param>
        /// <exception cref="ModelReferenceException"> if element is not already added to the model </exception>
        public virtual void setReferenceTargetElement(ModelElementInstance referenceSourceElement, T referenceTargetElement)
        {
            ModelInstance        modelInstance             = referenceSourceElement.ModelInstance;
            string               referenceTargetIdentifier = referenceTargetAttribute.getValue(referenceTargetElement);
            ModelElementInstance existingElement           = modelInstance.getModelElementById(referenceTargetIdentifier);

            if (existingElement == null || !existingElement.Equals(referenceTargetElement))
            {
                throw new ModelReferenceException("Cannot create reference to model element " + referenceTargetElement + ": element is not part of model. Please connect element to the model first.");
            }
            else
            {
                setReferenceIdentifier(referenceSourceElement, referenceTargetIdentifier);
            }
        }
예제 #3
0
        protected internal virtual void performAddOperation(ModelElementInstanceImpl referenceSourceParentElement, Target referenceTargetElement)
        {
            ModelInstanceImpl    modelInstance             = referenceSourceParentElement.ModelInstance;
            string               referenceTargetIdentifier = referenceTargetAttribute.getValue(referenceTargetElement);
            ModelElementInstance existingElement           = modelInstance.getModelElementById(referenceTargetIdentifier);

            if (existingElement == null || !existingElement.Equals(referenceTargetElement))
            {
                throw new ModelReferenceException("Cannot create reference to model element " + referenceTargetElement + ": element is not part of model. Please connect element to the model first.");
            }
            else
            {
                ICollection <Source> referenceSourceElements = referenceSourceCollection.get(referenceSourceParentElement);
                Source referenceSourceElement = modelInstance.newInstance(referenceSourceType);
                referenceSourceElements.Add(referenceSourceElement);
                setReferenceIdentifier(referenceSourceElement, referenceTargetIdentifier);
            }
        }