コード例 #1
0
        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;
        }
コード例 #2
0
        internal C4Builder ComponentUsesContainer(string componentName, string containerName,
                                                  string description, string technology)
        {
            var component = _currentContainer.GetComponentWithName(componentName);
            var container = _currentSoftwareSystem.GetContainerWithName(containerName);

            component.Uses(container, description, technology);

            return(this);
        }