Пример #1
0
        public virtual ModelEntity.Connector Connect(ModelEntity.Element source, ModelEntity.Element target, ConnectorStereotype stereotype)
        {
            if (stereotype.Type == ConnectorType.Association && (source.Type.Equals(ElementType.Package.Name) || target.Type.Equals(ElementType.Package.Name)))
            {
                // seems strange but it's true; EA crashes if you try to create such a connection! Thus, we stop before it's getting really ugly.
                throw new ApplicationException(String.Format("Cannot create connection {0} - {1} - {2}", source, stereotype.Name, target));
            }

            var c = source.EaObject.Connectors.AddNew("", stereotype.Type.Name) as EA.Connector;

            c.Stereotype = stereotype.Name;
            c.SupplierID = target.Id;

            try
            {
                c.Update();
            }
            catch (Exception e)
            {
                throw new ApplicationException(c.GetLastError(), e);
            }

            SpecifyComposition(stereotype, c);
            SpecifyNavigateability(stereotype, c);

            source.EaObject.Connectors.Refresh();
            target.EaObject.Connectors.Refresh();

            return(Wrapper.Wrap(c));
        }
Пример #2
0
 public virtual Option <ModelEntity.Element> Instantiate(ModelEntity.Element classifier, ModelEntity.Package package, IEnumerable <ElementStereotype> stereotypes)
 {
     return((from stype in classifier.GetStereotype(stereotypes)
             from instanceType in stype.InstanceType
             let e = Create("", instanceType, package)
                     select e)
            .Select(e =>
     {
         e.EaObject.ClassifierID = classifier.Id;
         e.EaObject.Update();
         return e;
     }));
 }
Пример #3
0
 public ModelEntity.Package FindPackageContaining(ModelEntity.Element element)
 {
     return(GetPackage(element.EaObject.PackageID).Value);
 }