public UmlClassDiagramExplorer WithGraphDepth(int graphDepth) { _classDiagramConfiguration = _classDiagramConfiguration with { GraphDepth = graphDepth }; return(this); } }
public static MermaidMarkdown ToClassDiagram(this Type type, ClassDiagramConfiguration configuration = null) { var buffer = new StringBuilder(); buffer.AppendLine("classDiagram"); var types = new List <Type>(); var classRelationshipBuffer = new StringBuilder(); var classDefinitionBuffer = new StringBuilder(); var generateTypes = new HashSet <Type>(); CreateRelationships(type, configuration?.GraphDepth ?? 0, types, classRelationshipBuffer); foreach (var typeToDescribe in types.OrderBy(t => t.Name.ToLowerInvariant())) { if (generateTypes.Add(typeToDescribe)) { var className = CreateClassName(typeToDescribe); classDefinitionBuffer.AppendLine($"class {className}"); if (typeToDescribe.IsInterface) { classDefinitionBuffer.AppendLine($"<<interface>> {className}"); } foreach (var method in typeToDescribe.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance).OrderBy(m => m.Name.ToLowerInvariant())) { classDefinitionBuffer.AppendLine($"{className} : {CreateMethodSignature(method)}"); } classDefinitionBuffer.AppendLine(); } } buffer.AppendLine(classRelationshipBuffer.ToString()); buffer.AppendLine(classDefinitionBuffer.ToString()); return(new MermaidMarkdown(buffer.ToString()));
public UmlClassDiagramExplorer(Type type, ClassDiagramConfiguration classDiagramConfiguration) { _type = type; _classDiagramConfiguration = classDiagramConfiguration; }