Beispiel #1
0
 protected abstract void RenderEnumDefinition(StringBuilder builder, NamedTypeApiView nt);
 protected override void RenderClassDefinition(StringBuilder builder, NamedTypeApiView nt)
 {
     builder.Append(nt.Name);
 }
Beispiel #3
0
        public void Render(NamedTypeApiView nt, StringListApiView list, int indents = 0)
        {
            var builder = new StringBuilder();

            AppendIndents(builder, indents);
            if (nt.IsSealed)
            {
                RenderKeyword(builder, "sealed");
                builder.Append(" ");
            }
            RenderKeyword(builder, nt.Accessibility);
            builder.Append(" ");
            if (nt.IsStatic)
            {
                RenderKeyword(builder, "static");
                builder.Append(" ");
            }
            RenderKeyword(builder, nt.TypeKind);
            builder.Append(" ");

            indents++;

            switch (nt.TypeKind)
            {
            case ("enum"):
                RenderEnumDefinition(builder, nt);
                builder.Append(" ");

                if (nt.EnumUnderlyingType.Tokens[0].DisplayString != "int")
                {
                    builder.Append(": ");
                    Render(nt.EnumUnderlyingType, builder);
                    builder.Append(" ");
                }
                builder.Append("{");
                list.Add(new LineApiView(builder.ToString(), nt.Id));

                foreach (FieldApiView f in nt.Fields)
                {
                    builder = new StringBuilder();
                    AppendIndents(builder, indents);
                    builder.Append(f.Name).Append(" = ");
                    RenderValue(builder, f.Value.ToString());
                    builder.Append(",");
                    list.Add(new LineApiView(builder.ToString()));
                }

                builder = new StringBuilder();
                AppendIndents(builder, indents - 1);
                builder.Append("}");
                list.Add(new LineApiView(builder.ToString()));
                break;

            case ("delegate"):
                foreach (MethodApiView m in nt.Methods)
                {
                    if (m.Name.Equals("Invoke"))
                    {
                        Render(m.ReturnType, builder);
                        builder.Append(" ");
                        RenderName(builder, nt.Name);
                        builder.Append("(");

                        if (m.Parameters.Any())
                        {
                            foreach (ParameterApiView p in m.Parameters)
                            {
                                Render(p, builder);
                                builder.Append(", ");
                            }
                            builder.Length -= 2;
                        }
                    }
                }
                builder.Append(") { }");
                list.Add(new LineApiView(builder.ToString(), nt.Id));
                break;

            default:
                RenderClassDefinition(builder, nt);
                builder.Append(" ");

                if (nt.TypeParameters.Any())
                {
                    builder.Length -= 1;
                    RenderPunctuation(builder, "<");
                    foreach (var tp in nt.TypeParameters)
                    {
                        Render(tp, builder);
                        builder.Append(", ");
                    }
                    builder.Length -= 2;
                    RenderPunctuation(builder, ">");
                    builder.Append(" ");
                }

                // add any implemented types to string
                if (nt.Implementations.Any())
                {
                    builder.Append(": ");
                    foreach (var i in nt.Implementations)
                    {
                        Render(i, builder);
                        builder.Append(", ");
                    }
                    builder.Length -= 2;
                    builder.Append(" ");
                }
                builder.Append("{");
                list.Add(new LineApiView(builder.ToString(), nt.Id));

                // add any types declared in this type's body
                foreach (FieldApiView f in nt.Fields)
                {
                    Render(f, list, indents);
                }
                foreach (PropertyApiView p in nt.Properties)
                {
                    Render(p, list, indents);
                }
                foreach (EventApiView e in nt.Events)
                {
                    Render(e, list, indents);
                }
                foreach (MethodApiView m in nt.Methods)
                {
                    Render(m, list, indents);
                }
                foreach (NamedTypeApiView n in nt.NamedTypes)
                {
                    Render(n, list, indents);
                }

                builder = new StringBuilder();
                AppendIndents(builder, indents - 1);
                builder.Append("}");
                list.Add(new LineApiView(builder.ToString()));
                break;
            }
        }
 protected override void RenderClassDefinition(StringBuilder builder, NamedTypeApiView nt)
 {
     builder.Append("<a href=\"#\" id=\"").Append(EscapeHTML(nt.Id)).Append("\" class=\"class commentable\">").
     Append(EscapeHTML(nt.Name)).Append("</a>");
 }