コード例 #1
0
     public UmlClassDiagramExplorer WithGraphDepth(int graphDepth)
     {
         _classDiagramConfiguration = _classDiagramConfiguration with {
             GraphDepth = graphDepth
         };
         return(this);
     }
 }
コード例 #2
0
        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()));
コード例 #3
0
 public UmlClassDiagramExplorer(Type type, ClassDiagramConfiguration classDiagramConfiguration)
 {
     _type = type;
     _classDiagramConfiguration = classDiagramConfiguration;
 }