/// <summary> /// Writes the class diagram. /// </summary> /// <param name="interface">The interface.</param> /// <param name="useIncludes">if set to <c>true</c> [use includes].</param> /// <returns></returns> internal static string WriteClassDiagram(Models.Interface @interface, bool useIncludes = false) { string markup = Templates.Descriptor; markup = markup.Replace(TypeElement, "interface ").Replace(NameElement, @interface.Name).Replace(ProtoTypeElement, "").Replace(StereoTypeElement, ""); markup = markup.Replace(BodyElement, WriteBody(@interface)); var aggregates = Aggregations.Distinct().ToList(); Aggregations.Clear(); var composites = Compositions.Distinct().ToList(); Compositions.Clear(); aggregates.ForEach((n) => markup += Aggregate(@interface.Name, n)); composites.ForEach((n) => markup += Composite(@interface.Name, n)); return(markup); }
/// <summary> /// Writes the class diagram. /// </summary> /// <param name="class">The class.</param> /// <param name="useIncludes">if set to <c>true</c> [use includes].</param> /// <returns></returns> internal static string WriteClassDiagram(Models.Class @class, bool useIncludes = false) { string markup = Templates.Descriptor; if (@class.Module) { markup = markup.Replace(ProtoTypeElement, "").Replace(StereoTypeElement, string.Format(StereoType, "M", "application", "module ")); } else if (@class.Static && @class.Abstract) { markup = markup.Replace(ProtoTypeElement, "").Replace(StereoTypeElement, string.Format(StereoType, "S", "orchid", "static ")); } else if (@class.Abstract) { markup = markup.Replace(ProtoTypeElement, "abstract ").Replace(StereoTypeElement, ""); } else { markup = markup.Replace(ProtoTypeElement, "").Replace(StereoTypeElement, ""); } markup = markup.Replace(TypeElement, "class ").Replace(NameElement, @class.Name); markup = markup.Replace(BodyElement, WriteBody(@class)); if (@class.Implements != null) { markup += Lollipop(@class.Name, @class.Implements.Name); } if (@class.Inherits != null) { markup += Extend(@class.Name, @class.Inherits.Name); } var aggregates = Aggregations.Distinct().ToList(); Aggregations.Clear(); var composites = Compositions.Distinct().ToList(); Compositions.Clear(); var consumption = Consumers.Distinct().ToList(); Consumers.Clear(); var provision = Providers.Distinct().ToList(); Providers.Clear(); aggregates.ForEach((n) => { if (useIncludes) { markup = ((IncludeDiagram(n).Length > 0) ? IncludeDiagram(n) : "") + markup; } markup += Aggregate(@class.Name, n); Relationships.Add(new Models.Relationship { PrincipalObject = @class, AncillaryObject = new Models.Generic { Name = n }, Type = Models.RelationshipType.Aggregation }); }); composites.ForEach((n) => { if (useIncludes) { markup = ((IncludeDiagram(n).Length > 0) ? IncludeDiagram(n) : "") + markup; } markup += Composite(@class.Name, n); Relationships.Add(new Models.Relationship { PrincipalObject = @class, AncillaryObject = new Models.Generic { Name = n }, Type = Models.RelationshipType.Composition }); }); consumption.ForEach((n) => { if (useIncludes) { markup = ((IncludeDiagram(n).Length > 0) ? IncludeDiagram(n) : "") + markup; } markup += Consumes(@class.Name, n); Relationships.Add(new Models.Relationship { PrincipalObject = @class, AncillaryObject = new Models.Generic { Name = n }, Type = Models.RelationshipType.Dependency }); }); Providers.ForEach((n) => { if (useIncludes) { markup = ((IncludeDiagram(n).Length > 0) ? IncludeDiagram(n) : "") + markup; } markup += Provides(@class.Name, n); Relationships.Add(new Models.Relationship { PrincipalObject = @class, AncillaryObject = new Models.Generic { Name = n }, Type = Models.RelationshipType.Association }); }); return(markup); }