Exemplo n.º 1
0
        public void Render(
            StringBuilder builder,
            bool isPublic,
            bool isInnerClass,
            CodegenIndent indent,
            int additionalIndent)
        {
            if (OptionalComment != null) {
                indent.Indent(builder, 1 + additionalIndent);
                builder.Append("// ");
                builder.Append(OptionalComment);
                builder.Append("\n");
            }

            indent.Indent(builder, 1 + additionalIndent);
            if (isPublic) {
                builder.Append("public ");
            }

            if (Modifiers.IsOverride()) {
                builder.Append("override ");
            }
            if (Modifiers.IsVirtual()) {
                builder.Append("virtual ");
            }

            if (ReturnType != null) {
                AppendClassName(builder, ReturnType);
            }
            else {
                builder.Append(ReturnTypeName);
            }

            builder.Append(" ");
            builder.Append(Name);
            builder.Append(" {\n");

            if (GetterBlock.IsNotEmpty()) {
                indent.Indent(builder, additionalIndent + 2);
                builder.Append("get {\n");
                GetterBlock.Render(builder, isInnerClass, 3 + additionalIndent, indent);
                indent.Indent(builder, additionalIndent + 2);
                builder.Append("}\n");
            }

            if (SetterBlock.IsNotEmpty()) {
                indent.Indent(builder, additionalIndent + 2);
                builder.Append("set {\n");
                SetterBlock.Render(builder, isInnerClass, 3 + additionalIndent, indent);
                indent.Indent(builder, additionalIndent + 2);
                builder.Append("}\n");
            }

            indent.Indent(builder, 1 + additionalIndent);
            builder.Append("}\n");
        }
Exemplo n.º 2
0
 public void MergeClasses(ISet<Type> classes)
 {
     classes.AddToSet(ReturnType);
     GetterBlock.MergeClasses(classes);
     SetterBlock.MergeClasses(classes);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Generates the mutator for the property.
 /// </summary>
 /// <returns></returns>
 private AccessorDeclarationSyntax GetMutator()
 {
     return AccessorDeclaration(SyntaxKind.SetAccessorDeclaration)
         .WithBody(SetterBlock.CodegenSyntax());
 }