예제 #1
0
        protected PersonBase(Workspace workspace, Action <ElementType, string> onCreatedFromExistingElement)
            : base(workspace.Views.Configuration.Styles, onCreatedFromExistingElement)
        {
            Workspace = workspace;
            if (!TryGetMetadata(out string description, out Location location))
            {
                throw new System.Exception($"Missing PersonAttribute on Person {GetType().Name}");
            }

            StyleContainer = workspace.Views.Configuration.Styles;
            Styles         = new ElementStyleBase[0];

            var name   = NamedIdentity.GetNameFromType(GetType());
            var person = workspace.Model.GetPersonWithName(name);

            if (person == null)
            {
                person = workspace.Model.AddPerson(location, name, description);
            }
            else
            {
                onCreatedFromExistingElement(ElementType.Element, person.Id);
                person.Location    = location;
                person.Description = description;
            }
            Element = Me = person;
        }
예제 #2
0
        protected SoftwareSystemBase(Workspace workspace, Action <ElementType, string> onCreatedFromExistingElement)
            : base(workspace.Views.Configuration.Styles, onCreatedFromExistingElement)
        {
            Workspace = workspace;
            _onCreatedFromExistingElement = onCreatedFromExistingElement;

            Styles     = new ElementStyleBase[0];
            Containers = new ContainerBase[0];

            if (!TryGetMetadata(out string description, out Location location))
            {
                throw new System.Exception($"Missing SoftwareSystemAttribute on SoftwareSystem {GetType().Name}");
            }
            StyleContainer = workspace.Views.Configuration.Styles;
            var name           = NamedIdentity.GetNameFromType(GetType());
            var softwareSystem = workspace.Model.GetSoftwareSystemWithName(name);

            if (softwareSystem == null)
            {
                softwareSystem = workspace.Model.AddSoftwareSystem(location, name, description);
            }
            else
            {
                onCreatedFromExistingElement(ElementType.Element, softwareSystem.Id);
                softwareSystem.Location    = location;
                softwareSystem.Description = description;
            }
            Element = Me = softwareSystem;
        }
        protected ContainerBase(SoftwareSystem softwareSystem, Structurizr.Styles styleContainer, Action <ElementType, string> onCreatedFromExistingElement)
            : base(styleContainer, onCreatedFromExistingElement)
        {
            if (!TryGetMetadata(out string description, out string technology))
            {
                throw new System.Exception($"Missing ContainerAttribute on Container class {GetType().Name}");
            }

            SoftwareSystem = softwareSystem;
            StyleContainer = styleContainer;
            _onCreatedFromExistingElement = onCreatedFromExistingElement;

            Components = new ComponentBase[0];
            Styles     = new ElementStyleBase[0];

            var name      = NamedIdentity.GetNameFromType(GetType());
            var container = softwareSystem.GetContainerWithName(name);

            if (container == null)
            {
                container = softwareSystem.AddContainer(name, description, technology);
            }
            else
            {
                _onCreatedFromExistingElement(ElementType.Element, container.Id);
                container.Description = description;
                container.Technology  = technology;
            }
            Element = Me = container;
        }
        protected RelationshipStyleBase(Structurizr.Styles styles, Action <ElementType, string> onCreatedFromExistingElement)
        {
            var styleName = NamedIdentity.GetNameFromType(GetType());
            var tagName   = styleName.Substring(0, styleName.Length - " Line Style".Length);

            _default = styles.Relationships.FirstOrDefault(x => x.Tag == tagName);
            if (_default == null)
            {
                _default = new RelationshipStyle(tagName);
                styles.Relationships.Add(_default);
            }
            else
            {
                onCreatedFromExistingElement(ElementType.RelationStyle, tagName);
            }
        }
        public DefaultStyles(Structurizr.Styles styles, Action <ElementType, string> onCreatedFromExistingElement)
        {
            _elementStyle = styles.Elements.FirstOrDefault(x => x.Tag == "Element");
            if (_elementStyle == null)
            {
                _elementStyle = new ElementStyle("Element");
                styles.Elements.Add(_elementStyle);
            }

            Person          = new PersonStyle(styles, onCreatedFromExistingElement);
            SoftwareSystem  = new SoftwareSystemStyle(styles, onCreatedFromExistingElement);
            Container       = new ContainerStyle(styles, onCreatedFromExistingElement);
            Component       = new ComponentStyle(styles, onCreatedFromExistingElement);
            AsyncLineStyle  = new AsynchronousLineStyle(styles, onCreatedFromExistingElement);
            SyncLineStyle   = new SynchronousLineStyle(styles, onCreatedFromExistingElement);
            DependencyStyle = new DependencyStyle(styles, onCreatedFromExistingElement);
        }
        protected ComponentBase(Container container, Structurizr.Styles styleContainer, Action <ElementType, string> onCreatedFromExistingElement)
            : base(styleContainer, onCreatedFromExistingElement)
        {
            if (!TryGetMetadata(out string description, out string technology, out string type))
            {
                throw new System.Exception($"Missing ComponentAttribute on Component {GetType().Name}");
            }

            StyleContainer = styleContainer;
            Styles         = new ElementStyleBase[0];

            var name      = NamedIdentity.GetNameFromType(GetType());
            var component = container.GetComponentWithName(name);

            if (component == null)
            {
                if (type.Length > 0)
                {
                    try
                    {
                        component = container.AddComponent(name, description, technology, type);
                    }
                    catch (System.ArgumentOutOfRangeException)
                    {
                        throw new System.Exception($"The type parameter in the ComponentAttribute on {name} has an invalid value");
                    }
                }
                else
                {
                    component = container.AddComponent(name, description, technology);
                }
            }
            else
            {
                onCreatedFromExistingElement(ElementType.Element, component.Id);
                component.Description = description;
                component.Technology  = technology;
                component.Type        = type;
            }
            Element = Me = component;
        }
예제 #7
0
 public FutureStateStyle(Structurizr.Styles styles, Action <ElementType, string> onCreatedFromExistingElement)
     : base(styles, onCreatedFromExistingElement)
 {
     SetOpacity(30);
     SetBorder(Border.Dashed);
 }
 protected virtual void ApplyDefaultStyles(Structurizr.Styles styles)
 {
     AdaptDefaultStyles();
 }
예제 #9
0
 protected ElementBase(Structurizr.Styles styleContainer, Action <ElementType, string> onCreatedFromExistingElement)
 {
     _styleContainer = styleContainer;
     _onCreatedFromExistingElement = onCreatedFromExistingElement;
     Connectors = new Connector[0];
 }