Пример #1
0
        /// <summary>
        /// Adds a software system instance to this deployment node, optionally replicating relationships.
        /// </summary>
        /// <param name="softwareSystem">the SoftwareSystem to add an instance of</param>
        /// <param name="deploymentGroup">the deployment group</param>
        /// <returns>a SoftwareSystemInstance object</returns>
        public SoftwareSystemInstance Add(SoftwareSystem softwareSystem, string deploymentGroup)
        {
            if (softwareSystem == null)
            {
                throw new ArgumentException("A software system must be specified.");
            }

            SoftwareSystemInstance softwareSystemInstance = Model.AddSoftwareSystemInstance(this, softwareSystem, deploymentGroup);

            _softwareSystemInstances.Add(softwareSystemInstance);

            return(softwareSystemInstance);
        }
Пример #2
0
        /// <summary>
        /// Adds a software system instance to this deployment node, optionally replicating relationships.
        /// </summary>
        /// <param name="softwareSystem">the SoftwareSystem to add an instance of</param>
        /// <param name="replicateRelationships">true if relationships should be replicated between the element instances in the same deployment environment, false otherwise</param>
        /// <returns>a SoftwareSystemInstance object</returns>
        public SoftwareSystemInstance Add(SoftwareSystem softwareSystem, bool replicateRelationships)
        {
            if (softwareSystem == null)
            {
                throw new ArgumentException("A software system must be specified.");
            }

            SoftwareSystemInstance softwareSystemInstance = Model.AddSoftwareSystemInstance(this, softwareSystem, replicateRelationships);

            _softwareSystemInstances.Add(softwareSystemInstance);

            return(softwareSystemInstance);
        }
Пример #3
0
        public SystemContextView CreateSystemContextView(SoftwareSystem softwareSystem, string key, string description)
        {
            if (GetViewWithKey(key) != null)
            {
                throw new ArgumentException("A view with the key " + key + " already exists.");
            }
            else
            {
                SystemContextView view = new SystemContextView(softwareSystem, key, description);
                this.SystemContextViews.Add(view);

                return(view);
            }
        }
Пример #4
0
        internal View(SoftwareSystem softwareSystem, string key, string description) : this()
        {
            this.SoftwareSystem = softwareSystem;
            if (key != null && key.Trim().Length > 0)
            {
                this.Key = key;
            }
            else
            {
                throw new ArgumentException("A key must be specified.");
            }
            this.Description = description;

            _elements      = new HashSet <ElementView>();
            _relationships = new HashSet <RelationshipView>();
        }
Пример #5
0
        public DynamicView CreateDynamicView(SoftwareSystem softwareSystem, string key, string description)
        {
            if (softwareSystem == null)
            {
                throw new ArgumentException("Software system must not be null.");
            }

            if (GetViewWithKey(key) != null)
            {
                throw new ArgumentException("A view with the key " + key + " already exists.");
            }
            else
            {
                DynamicView view = new DynamicView(softwareSystem, key, description);
                DynamicViews.Add(view);
                return(view);
            }
        }
Пример #6
0
        /// <summary>
        /// Creates a software system (location is unspecified) and adds it to the model
        /// (unless one exists with the same name already).
        /// </summary>
        /// <param name="location">The location of the software system (e.g. internal, external, etc)</param>
        /// <param name="name">The name of the software system</param>
        /// <param name="description">A short description of the software syste.</param>
        /// <returns>the SoftwareSystem instance created and added to the model (or null)</returns>
        public SoftwareSystem AddSoftwareSystem(Location location, string name, string description)
        {
            if (GetSoftwareSystemWithName(name) == null)
            {
                SoftwareSystem softwareSystem = new SoftwareSystem();
                softwareSystem.Location    = location;
                softwareSystem.Name        = name;
                softwareSystem.Description = description;

                _softwareSystems.Add(softwareSystem);

                softwareSystem.Id = _idGenerator.GenerateId(softwareSystem);
                AddElementToInternalStructures(softwareSystem);

                return(softwareSystem);
            }
            else
            {
                return(null);
            }
        }
Пример #7
0
        internal Container AddContainer(SoftwareSystem parent, string name, string description, string technology)
        {
            if (parent.GetContainerWithName(name) == null)
            {
                Container container = new Container();
                container.Name        = name;
                container.Description = description;
                container.Technology  = technology;

                container.Parent = parent;
                parent.Add(container);

                container.Id = _idGenerator.GenerateId(container);
                AddElementToInternalStructures(container);

                return(container);
            }
            else
            {
                return(null);
            }
        }
 internal StaticView(SoftwareSystem softwareSystem, string key, string description) : base(softwareSystem, key, description)
 {
     Animations = new List <Animation>();
 }
Пример #9
0
        static void Main(string[] args)
        {
            Workspace workspace = new Workspace("Contoso University", "A software architecture model of the Contoso University sample project.");
            Model     model     = workspace.Model;
            ViewSet   views     = workspace.Views;
            Styles    styles    = views.Configuration.Styles;

            Person         universityStaff   = model.AddPerson("University Staff", "A staff member of the Contoso University.");
            SoftwareSystem contosoUniversity = model.AddSoftwareSystem("Contoso University", "Allows staff to view and update student, course, and instructor information.");

            universityStaff.Uses(contosoUniversity, "uses");

            // if the client-side of this application was richer (e.g. it was a single-page app), I would include the web browser
            // as a container (i.e. User --uses-> Web Browser --uses-> Web Application (backend for frontend) --uses-> Database)
            Container webApplication = contosoUniversity.AddContainer("Web Application", "Allows staff to view and update student, course, and instructor information.", "Microsoft ASP.NET MVC");
            Container database       = contosoUniversity.AddContainer("Database", "Stores information about students, courses and instructors", "Microsoft SQL Server Express LocalDB");

            database.AddTags("Database");
            universityStaff.Uses(webApplication, "Uses", "HTTPS");
            webApplication.Uses(database, "Reads from and writes to");

            ComponentFinder componentFinder = new ComponentFinder(
                webApplication,
                typeof(ContosoUniversity.MvcApplication).Namespace, // doing this typeof forces the ContosoUniversity assembly to be loaded
                new TypeBasedComponentFinderStrategy(
                    new InterfaceImplementationTypeMatcher(typeof(System.Web.Mvc.IController), null, "ASP.NET MVC Controller"),
                    new ExtendsClassTypeMatcher(typeof(System.Data.Entity.DbContext), null, "Entity Framework DbContext")
                    )
                //new TypeSummaryComponentFinderStrategy(@"C:\Users\simon\ContosoUniversity\ContosoUniversity.sln", "ContosoUniversity")
                );

            componentFinder.FindComponents();

            // connect the user to the web MVC controllers
            webApplication.Components.ToList().FindAll(c => c.Technology == "ASP.NET MVC Controller").ForEach(c => universityStaff.Uses(c, "uses"));

            // connect all DbContext components to the database
            webApplication.Components.ToList().FindAll(c => c.Technology == "Entity Framework DbContext").ForEach(c => c.Uses(database, "Reads from and writes to"));

            // link the components to the source code
            foreach (Component component in webApplication.Components)
            {
                foreach (CodeElement codeElement in component.Code)
                {
                    if (codeElement.Url != null)
                    {
                        codeElement.Url = codeElement.Url.Replace(new Uri(@"C:\Users\simon\ContosoUniversity\").AbsoluteUri, "https://github.com/simonbrowndotje/ContosoUniversity/blob/master/");
                        codeElement.Url = codeElement.Url.Replace('\\', '/');
                    }
                }
            }

            // rather than creating a component model for the database, let's simply link to the DDL
            // (this is really just an example of linking an arbitrary element in the model to an external resource)
            database.Url = "https://github.com/simonbrowndotje/ContosoUniversity/tree/master/ContosoUniversity/Migrations";

            SystemContextView contextView = views.CreateSystemContextView(contosoUniversity, "Context", "The system context view for the Contoso University system.");

            contextView.AddAllElements();

            ContainerView containerView = views.CreateContainerView(contosoUniversity, "Containers", "The containers that make up the Contoso University system.");

            containerView.AddAllElements();

            ComponentView componentView = views.CreateComponentView(webApplication, "Components", "The components inside the Contoso University web application.");

            componentView.AddAllElements();

            // create an example dynamic view for a feature
            DynamicView dynamicView      = views.CreateDynamicView(webApplication, "GetCoursesForDepartment", "A summary of the \"get courses for department\" feature.");
            Component   courseController = webApplication.GetComponentWithName("CourseController");
            Component   schoolContext    = webApplication.GetComponentWithName("SchoolContext");

            dynamicView.Add(universityStaff, "Requests the list of courses from", courseController);
            dynamicView.Add(courseController, "Uses", schoolContext);
            dynamicView.Add(schoolContext, "Gets a list of courses from", database);

            // add some styling
            styles.Add(new ElementStyle(Tags.Person)
            {
                Background = "#0d4d4d", Color = "#ffffff", Shape = Shape.Person
            });
            styles.Add(new ElementStyle(Tags.SoftwareSystem)
            {
                Background = "#003333", Color = "#ffffff"
            });
            styles.Add(new ElementStyle(Tags.Container)
            {
                Background = "#226666", Color = "#ffffff"
            });
            styles.Add(new ElementStyle("Database")
            {
                Shape = Shape.Cylinder
            });
            styles.Add(new ElementStyle(Tags.Component)
            {
                Background = "#407f7f", Color = "#ffffff"
            });

            StructurizrClient structurizrClient = new StructurizrClient("20e54135-adff-4bdf-b684-ff6c3ffc478f", "1c714777-3b06-4e2a-9eb4-35a3648b1592");

            structurizrClient.MergeWorkspace(32431, workspace);
        }
Пример #10
0
 /// <summary>
 /// Adds a software system instance to this deployment node, replicating relationships.
 /// </summary>
 /// <param name="softwareSystem">the SoftwareSystem to add an instance of</param>
 /// <returns>a SoftwareSystemInstance object</returns>
 public SoftwareSystemInstance Add(SoftwareSystem softwareSystem)
 {
     return(Add(softwareSystem, true));
 }
Пример #11
0
 public Section Add(SoftwareSystem softwareSystem, SectionType type, DocumentationFormat format, string content)
 {
     return(AddSection(softwareSystem, type, format, content));
 }
Пример #12
0
 internal DeploymentView(SoftwareSystem softwareSystem, string key, string description) : base(softwareSystem,
                                                                                               key, description)
 {
     Model = softwareSystem.Model;
 }
Пример #13
0
 internal ContainerView(SoftwareSystem softwareSystem, string key, string description) : base(softwareSystem, key, description)
 {
 }
Пример #14
0
        public Section Add(SoftwareSystem softwareSystem, SectionType type, DocumentationFormat format, FileInfo fileInfo)
        {
            string content = File.ReadAllText(fileInfo.FullName, Encoding.UTF8);

            return(Add(softwareSystem, type, format, content));
        }
Пример #15
0
 internal SystemContextView(SoftwareSystem softwareSystem, string key, string description) : base(softwareSystem, key, description)
 {
     AddElement(softwareSystem, true);
 }
Пример #16
0
 /// <summary>
 /// Adds a software system instance to this deployment node, replicating relationships.
 /// </summary>
 /// <param name="softwareSystem">the SoftwareSystem to add an instance of</param>
 /// <returns>a SoftwareSystemInstance object</returns>
 public SoftwareSystemInstance Add(SoftwareSystem softwareSystem)
 {
     return(Add(softwareSystem, DefaultDeploymentGroup));
 }
Пример #17
0
        internal SoftwareSystemInstance AddSoftwareSystemInstance(DeploymentNode deploymentNode, SoftwareSystem softwareSystem, bool replicateRelationships)
        {
            if (softwareSystem == null)
            {
                throw new ArgumentException("A software system must be specified.");
            }

            long instanceNumber = deploymentNode.SoftwareSystemInstances.Count(ssi => ssi.SoftwareSystem.Equals(softwareSystem));

            instanceNumber++;
            SoftwareSystemInstance softwareSystemInstance = new SoftwareSystemInstance(softwareSystem, (int)instanceNumber, deploymentNode.Environment);

            softwareSystemInstance.Parent = deploymentNode;
            softwareSystemInstance.Id     = IdGenerator.GenerateId(softwareSystemInstance);

            if (replicateRelationships)
            {
                ReplicateElementRelationships(deploymentNode.Environment, softwareSystemInstance);
            }

            AddElementToInternalStructures(softwareSystemInstance);

            return(softwareSystemInstance);
        }
Пример #18
0
 internal DynamicView(SoftwareSystem softwareSystem, string key, string description) : base(softwareSystem, key, description)
 {
     Model   = softwareSystem.Model;
     Element = softwareSystem;
 }
Пример #19
0
 internal DeploymentView(SoftwareSystem softwareSystem, string key, string description) : base(softwareSystem,
                                                                                               key, description)
 {
     Model       = softwareSystem.Model;
     Environment = DeploymentElement.DefaultDeploymentEnvironment;
 }
Пример #20
0
 /// <summary>
 /// Removes the given SoftwareSystem from this view.
 /// </summary>
 /// <param name="softwareSystem"></param>
 public void Remove(SoftwareSystem softwareSystem)
 {
     RemoveElement(softwareSystem);
 }
Пример #21
0
 /// <summary>
 /// Adds the given SoftwareSystem to this view.
 /// </summary>
 public virtual void Add(SoftwareSystem softwareSystem)
 {
     AddElement(softwareSystem, true);
 }
Пример #22
0
 internal StaticView(SoftwareSystem softwareSystem, string key, string description) : base(softwareSystem, key, description)
 {
 }
Пример #23
0
 internal string Generate(SoftwareSystem softwareSystem)
 {
     return(SoftwareSystemType + formatName(softwareSystem));
 }