コード例 #1
0
        public DynamicView CreateDynamicView(string key, string description)
        {
            AssertThatTheViewKeyIsUnique(key);

            DynamicView view = new DynamicView(Model, key, description);

            _dynamicViews.Add(view);
            return(view);
        }
コード例 #2
0
        public void CopyLayoutInformationFrom(ViewSet source)
        {
            foreach (SystemLandscapeView sourceView in source.SystemLandscapeViews)
            {
                SystemLandscapeView destinationView = FindSystemLandscapeView(sourceView);
                if (destinationView != null)
                {
                    destinationView.CopyLayoutInformationFrom(sourceView);
                }
            }

            foreach (SystemContextView sourceView in source.SystemContextViews)
            {
                SystemContextView destinationView = FindSystemContextView(sourceView);
                if (destinationView != null)
                {
                    destinationView.CopyLayoutInformationFrom(sourceView);
                }
            }

            foreach (ContainerView sourceView in source.ContainerViews)
            {
                ContainerView destinationView = FindContainerView(sourceView);
                if (destinationView != null)
                {
                    destinationView.CopyLayoutInformationFrom(sourceView);
                }
            }

            foreach (ComponentView sourceView in source.ComponentViews)
            {
                ComponentView destinationView = FindComponentView(sourceView);
                if (destinationView != null)
                {
                    destinationView.CopyLayoutInformationFrom(sourceView);
                }
            }

            foreach (DynamicView sourceView in source.DynamicViews)
            {
                DynamicView destinationView = FindDynamicView(sourceView);
                if (destinationView != null)
                {
                    destinationView.CopyLayoutInformationFrom(sourceView);
                }
            }

            foreach (DeploymentView sourceView in source.DeploymentViews)
            {
                DeploymentView destinationView = FindDeploymentView(sourceView);
                if (destinationView != null)
                {
                    destinationView.CopyLayoutInformationFrom(sourceView);
                }
            }
        }
コード例 #3
0
        public DynamicView CreateDynamicView(Container container, string key, string description)
        {
            AssertThatTheContainerIsNotNull(container);
            AssertThatTheViewKeyIsUnique(key);

            DynamicView view = new DynamicView(container, key, description);

            _dynamicViews.Add(view);
            return(view);
        }
コード例 #4
0
        public DynamicView CreateDynamicView(SoftwareSystem softwareSystem, string key, string description)
        {
            AssertThatTheSoftwareSystemIsNotNull(softwareSystem);
            AssertThatTheViewKeyIsUnique(key);

            DynamicView view = new DynamicView(softwareSystem, key, description);

            _dynamicViews.Add(view);
            return(view);
        }
コード例 #5
0
ファイル: ViewSet.cs プロジェクト: fhchina/dotnet-1
 public DynamicView CreateDynamicView(string key, string description)
 {
     if (GetViewWithKey(key) != null)
     {
         throw new ArgumentException("A view with the key " + key + " already exists.");
     }
     else
     {
         DynamicView view = new DynamicView(Model, key, description);
         DynamicViews.Add(view);
         return(view);
     }
 }
コード例 #6
0
ファイル: ViewSet.cs プロジェクト: fhchina/dotnet-1
        public DynamicView CreateDynamicView(Container container, string key, string description)
        {
            if (container == null)
            {
                throw new ArgumentException("Container must not be null.");
            }

            if (GetViewWithKey(key) != null)
            {
                throw new ArgumentException("A view with the key " + key + " already exists.");
            }
            else
            {
                DynamicView view = new DynamicView(container, key, description);
                DynamicViews.Add(view);
                return(view);
            }
        }
コード例 #7
0
ファイル: ViewSet.cs プロジェクト: fhchina/dotnet-1
        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);
            }
        }
コード例 #8
0
 private DynamicView FindDynamicView(DynamicView dynamicView)
 {
     return(_dynamicViews.FirstOrDefault(view => view.Key == dynamicView.Key));
 }
コード例 #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);
        }