private static void ConnectToComponent(Connector connector, StaticStructureElement fromElement)
        {
            var connectedSystem = _workspace.Model.SoftwareSystems.SelectMany(x => x.Containers)
                                  .SelectMany(x => x.Components)
                                  .FirstOrDefault(x => x.Name == NamedIdentity.GetNameFromType(connector.ConnectTo));

            if (connectedSystem == null)
            {
                return;
            }

            var ctor = connector.RelationshipStyle.GetConstructor(new[] { typeof(Structurizr.Styles), typeof(Action <ElementType, string>) });

            if (ctor == null)
            {
                return;
            }
            Action <ElementType, string> callback = OnCreatedFromExistingElement;
            var connectorStyle = (RelationshipStyleBase)ctor.Invoke(new object[] { _workspace.Views.Configuration.Styles, callback });

            var relationship = fromElement.Relationships.FirstOrDefault(x => x.DestinationId == connectedSystem.Id)
                               ?? fromElement.Uses(connectedSystem, connector.Description, connector.Technology, connectorStyle.InteractionStyle);

            relationship.AddUniqueTag(connectorStyle.GetRelationshipStyle().Tag);
        }
        private static List <SoftwareSystemBase> ConnectToSoftwareSystem(Connector connector, StaticStructureElement fromElement)
        {
            var softwareSystemDependencies = new List <SoftwareSystemBase>();
            var connectedSystem            =
                _workspace.Model.GetSoftwareSystemWithName(NamedIdentity.GetNameFromType(connector.ConnectTo));

            if (connectedSystem == null)
            {
                //possibly from another library: for now only allow SoftwareSystem (loose containers and components are not allowed)
                if (!typeof(SoftwareSystemBase).IsAssignableFrom(connector.ConnectTo))
                {
                    return(softwareSystemDependencies);
                }

                var softwareSystem = CreateExternalSoftwareSystem(connector.ConnectTo);
                softwareSystemDependencies.Add(softwareSystem);
                connectedSystem = softwareSystem.Me;
            }

            var ctor = connector.RelationshipStyle.GetConstructor(new[] { typeof(Structurizr.Styles), typeof(Action <ElementType, string>) });

            if (ctor == null)
            {
                return(softwareSystemDependencies);
            }
            Action <ElementType, string> callback = OnCreatedFromExistingElement;
            var connectorStyle = (RelationshipStyleBase)ctor.Invoke(new object[] { _workspace.Views.Configuration.Styles, callback });

            var relationship = fromElement.Relationships.FirstOrDefault(x => x.DestinationId == connectedSystem.Id)
                               ?? fromElement.Uses(connectedSystem, connector.Description, connector.Technology, connectorStyle.InteractionStyle);

            relationship.AddUniqueTag(connectorStyle.GetRelationshipStyle().Tag);
            return(softwareSystemDependencies);
        }