Exemple #1
0
 public IEnumerable <E> ElementsConnectedBy <E>(ConnectorStereotype cstype, Func <int, Option <ModelEntity.Element> > getElementById)
     where E : Element
 {
     return(from element in ElementsConnectedBy(cstype, getElementById)
            from e in element.TryCast <E>()
            select e);
 }
Exemple #2
0
 public IEnumerable <Element> ElementsConnectedBy(ConnectorStereotype cstype, Func <int, Option <ModelEntity.Element> > getElementById)
 {
     return(from connector in Connectors
            where connector.Is(cstype)
            from source in connector.OppositeEnd(this, getElementById)
            select source);
 }
 private IEnumerable <Tuple <TSource, IEnumerable <TTarget> > > FindTargetsPerSource <TSource, TTarget>(
     IEnumerable <ModelEntity.Element> elements, ConnectorStereotype connectorStype)
     where TSource : ModelEntity.Element
     where TTarget : ModelEntity.Element
 {
     return((from e in elements
             from source in e.TryCast <TSource>()
             let targets = source.ElementsConnectedBy <TTarget>(connectorStype, Repository.GetElement).Run()
                           select Tuple.Create(source, targets)).Run());
 }
        private static void SpecifyNavigateability(ConnectorStereotype stereotype, EA.Connector c)
        {
            var direction = stereotype.Direction.GetOrElse((stereotype.Type as ConnectorType).DefaultDirection);

            if (c.ClientEnd.Navigable != direction.SourceNavigateability.Name)
            {
                c.ClientEnd.Navigable = direction.SourceNavigateability.Name;
                c.ClientEnd.Update();
            }
            if (c.SupplierEnd.Navigable != direction.TargetNavigateability.Name)
            {
                c.SupplierEnd.Navigable = direction.TargetNavigateability.Name;
                c.SupplierEnd.Update();
            }
        }
 private static void SpecifyComposition(ConnectorStereotype stereotype, EA.Connector c)
 {
     stereotype.CompositionKind.Do(compositionKind =>
     {
         var end =
             compositionKind.End == CompositionKind.CompositionEnd.Source ? c.ClientEnd.AsOption() :
             compositionKind.End == CompositionKind.CompositionEnd.Target ? c.SupplierEnd.AsOption() :
             Options.None <EA.ConnectorEnd>();
         end.Do(e =>
         {
             e.Aggregation = (int)compositionKind.Type;
             e.Update();
         });
     });
 }
        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));
        }
Exemple #7
0
 public bool Is(ConnectorStereotype connectorStereotype)
 {
     return(Stereotype.Equals(connectorStereotype.Name) && Type.Equals(connectorStereotype.Type.Name));
 }