Exemplo n.º 1
0
        internal static string GetInterfaceDocumentation(string @namespace, Models.Interface @interface)
        {
            string docDetail = string.Empty;

            if (@interface.Properties.Count > 0)
            {
                docDetail += ("###Properties" + Environment.NewLine);
            }
            @interface.Properties.ForEach((p) =>
            {
                docDetail += p.Documentation;
            });
            if (@interface.Functions.Count > 0)
            {
                docDetail += ("###Functions" + Environment.NewLine);
            }
            @interface.Functions.ForEach((f) =>
            {
                docDetail += f.Documentation;
            });
            if (@interface.Voids.Count > 0)
            {
                docDetail += ("###Actions" + Environment.NewLine);
            }
            @interface.Voids.ForEach((v) =>
            {
                docDetail += v.Documentation;
            });

            return(string.Format(Template(Templates.ClassTemplate, @namespace, @interface.Name), @interface.Name, docDetail, string.Format(Templates.DiagramTemplate, @interface.Name, @interface.DiagramUrl), string.Format(Title, @namespace.ToLower())));
        }
        /// <summary>
        /// Writes the body.
        /// </summary>
        /// <param name="interface">The interface.</param>
        /// <returns></returns>
        private static string WriteBody(Models.Interface @interface)
        {
            string Body = string.Empty;

            WriteProperties(@interface.Properties).ForEach((n) => Body += (n + '\n'));
            WriteVoids(@interface.Voids).ForEach((n) => Body           += (n + Environment.NewLine));
            WriteFunctions(@interface.Functions).ForEach((n) => Body   += (n + Environment.NewLine));

            return(Body);
        }
Exemplo n.º 3
0
        /// <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>
        /// 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);
        }