Esempio n. 1
0
        private TestModelBuilder AddRelationship(string sourceName, string targetName,
                                                 ModelRelationshipClassifier classifier, ModelRelationshipStereotype stereotype)
        {
            if (_testModel.Relationships
                .Any(i => i.Source.Name == sourceName && i.Classifier == classifier && i.Stereotype == stereotype && i.Target.Name == targetName))
            {
                throw new InvalidOperationException($"Relationship already exists {sourceName}--{classifier}({stereotype})-->{targetName}.");
            }

            var sourceEntity = _testModel.Entities.FirstOrDefault(i => i.Name == sourceName) as ModelEntity;

            if (sourceEntity == null)
            {
                throw new InvalidOperationException($"Entity with name {sourceName} not found.");
            }

            var targetEntity = _testModel.Entities.FirstOrDefault(i => i.Name == targetName) as ModelEntity;

            if (targetEntity == null)
            {
                throw new InvalidOperationException($"Entity with name {targetName} not found.");
            }

            var newRelationship = new ModelRelationship(sourceEntity, targetEntity, classifier, stereotype);

            _testModel.GetOrAddRelationship(newRelationship);

            return(this);
        }
        public ModelRelationship(IModelEntity source, IModelEntity target,
                                 ModelRelationshipClassifier classifier, ModelRelationshipStereotype stereotype)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }
            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }

            Source     = source;
            Target     = target;
            Classifier = classifier;
            Stereotype = stereotype;
        }
Esempio n. 3
0
 public EntityRelationType(string name, ModelRelationshipClassifier classifier, ModelRelationshipStereotype stereotype,
                           EntityRelationDirection direction)
     : this(name, new ModelRelationshipType(classifier, stereotype), direction)
 {
 }
 public ModelRelationshipType(ModelRelationshipClassifier classifier, ModelRelationshipStereotype stereotype)
 {
     Classifier = classifier;
     Stereotype = stereotype;
 }