/// <summary> /// Converts to interface. /// </summary> /// <param name="type">The type.</param> /// <returns></returns> private static Models.Interface ConvertToInterface(Type type) { var @interface = new Models.Interface { Name = Regex.Replace(type.Name, TypingSetter, ""), Properties = GetProperties(type), Functions = GetFunctions(type), Voids = GetVoids(type) }; @interface.Diagram = string.Format(Templates.PsuedoCode, AssemblyDiagrammer.WriteClassDiagram(@interface)); @interface.DiagramUrl = DiagramService.GetImageUrlForSource(@interface.Diagram, "svg"); @interface.Documentation = DocumentService.GetInterfaceDocumentation(type.Namespace, @interface); @interface.Relationships = AssemblyDiagrammer.GetRelationships(@interface); return(@interface); }
/// <summary> /// Lists the namespaces. /// </summary> /// <param name="assembly">The assembly.</param> /// <returns></returns> private static List <Models.Namespace> ListNamespaces(Assembly assembly) { var names = assembly.GetTypes().Select((t) => t.Namespace).Distinct().ToList(); names.Where((x) => (x != null) && (!string.IsNullOrEmpty(x)) && (!x.Contains("My.")) && (!x.Contains(".My"))).ToList().ForEach((n) => Namespaces.Add(new Models.Namespace { Name = n })); Namespaces.ForEach((n) => { Console.WriteLine(n.Name); GetTypes(assembly, n); n.Topography = AssemblyDiagrammer.MapTopography(n); n.TopographyUrl = DiagramService.GetImageUrlForSource(n.Topography, "svg"); n.Documentation = DocumentService.GetNamespaceDocumentation(n); }); return(Namespaces); }
/// <summary> /// Converts to class. /// </summary> /// <param name="type">The type.</param> /// <returns></returns> public static Models.Class ConvertToClass(Type type) { var @class = new Models.Class { Name = Regex.Replace(type.Name, TypingSetter, ""), Properties = GetProperties(type), Functions = GetFunctions(type), Voids = GetVoids(type), Abstract = type.IsAbstract, Static = IsStaticType(type), Module = IsModule(type), Implements = type.GetInterfaces().FirstOrDefault(), Inherits = (type.BaseType ?? null) }; @class.Diagram = string.Format(Templates.PsuedoCode, AssemblyDiagrammer.WriteClassDiagram(@class)); @class.DiagramUrl = DiagramService.GetImageUrlForSource(@class.Diagram, "svg"); @class.Documentation = DocumentService.GetClassDocumentation(type.Namespace, @class); @class.Relationships = AssemblyDiagrammer.GetRelationships(@class); return(@class); }
/// <summary> /// Converts to enum. /// </summary> /// <param name="type">The type.</param> /// <returns></returns> private static Models.Enum ConvertToEnum(Type type) { Dictionary <object, object> Values = new Dictionary <object, object>(); type.GetFields().ToList().ForEach((e) => { if (e.FieldType.IsEnum) { Values.Add(e.Name, e.GetRawConstantValue()); } }); var @enum = new Models.Enum { Name = Regex.Replace(type.Name, TypingSetter, ""), Values = Values }; @enum.Diagram = string.Format(Templates.PsuedoCode, AssemblyDiagrammer.WriteClassDiagram(@enum)); @enum.DiagramUrl = DiagramService.GetImageUrlForSource(@enum.Diagram, "svg"); @enum.Documentation = ""; return(@enum); }