![]() ![]() However, more powerful graphs can be generated by having DgmlBuilder execute graph analyses. The graphs produced by DgmlBuilder so far are pretty straight-forward graphs with nodes and edges. You can now open the file my-graph.dgml in the DGML viewer of Visual Studio to inspect and analyze the graph. There is also a convenient method available that does exactly this: graph.WriteToFile("my-graph.dgml") Var serializer = new XmlSerializer(typeof(DirectedGraph)) E.g., as follows: using (var writer = new StreamWriter("my-graph.dgml")) NET serializers you can save the corresponding graph to disk. The resulting DGML graph is a serializable object. Public DirectedGraph Build(params IEnumerable elements)`īoth build methods will apply the configured builders to all elements and produces a DGML graph as output.įor example, if you have your components, interfaces, and calls contained in separate collections, you can generate the corresponding DGML graph as follows: var graph = builder.Build(components, interfaces, calls) The second supports multiple collections:.Public DirectedGraph Build(IEnumerable elements) The first, simply accepts a collection of objects:.The DgmlBuilder class supports two Build methods: The basic setup is like this: var builder = new DgmlBuilderĪs you can see, all builder properties of DgmlBuilder are collections, allowing you to specify multiple builders for each. To use DgmlBuilder, you instantiate DgmlBuilder with the builders you need. In this example, the property IsPublic of a component is used to specify that the builder should only be applied to public components. For example, in case of the aforementioned node builder, we could add an accept parameter as follows: new NodeBuilder( Likewise, to generate multiple links at once, you can instantiate the LinksBuilder class.Įach builder has an optional accept parameter that can be used to specify when the builder should be applied to an element. E.g., you can create an instance of NodesBuilder for elements in your model for which you want multiple nodes in the resulting graph. While each of the above builder types generates a single node, there are also methods available to generate multiple nodes at once. For example, to use different background colors for components and interfaces. StyleBuilder These are builders for applying visual styles to your nodes and edges.Categories make it easy to style all nodes of a category consistently. CategoryBuilder These are builders for grouping nodes into categories.DgmlBuilder will use this information to place the target node as child of the source node. If a link denotes a containment relation, set the attribute IsContainment to true. For instance, if there is a Call relation in your model to represent method calls from one component to another, you could instantiate an link builder as follows: LinkBuilder These are builders for constructing links in your graph.For instance, if your model also contains Interface as type, you can instantiate a specific node builder for this type too. For instance, if you have a type Component in your model with Name, Id, and ComponentType properties, you can transform these into corresponding nodes with the following node builder:Īs we'll see shortly, you can define multiple node builders. NodeBuilder These are builders that construct graph nodes from objects in your model.Buildersīuilders are specific classes that you write to convert objects in your model to specific graph elements. DgmlBuilder for creating class diagramsĭgmlBuilder for visualizing Structurizr C4 modelsĭgmlBuilder operates on a collection of objects and turns these into collections of nodes, edges, styles, and categories, based on a given set of builders. The aim of DgmlBuilder is to make it more easy to represent your (graph-) structured data in DGML such that you can use the Visual Studio DGML viewer to display, analyze, and interact with your data.īelow are a few example pictures. Despite the powerful viewer, the DGML format is not so much in use for other purposes. Visual Studio contains a powerful, interactive DGML viewer that is used mostly for displaying code structures of your Visual Studio projects. DgmlBuilder is a small DotNet library for generating DGML graphs without having to know all the details of DGML (the Microsoft Directed Graph Markup Language). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |