Exemplo n.º 1
0
        public override void DumpTo(CodeWriter writer)
        {
            if (writer.Mode == CodeWriterMode.Full)
            {
                Comment?.DumpTo(writer);
            }
            this.DumpAttributesTo(writer);
            FieldType?.DumpContextualAttributesTo(writer);
            Visibility.DumpTo(writer);
            Modifiers.DumpTo(writer);

            if (FieldType is CSharpFixedArrayType fixedArrayType)
            {
                writer.Write("fixed ");
                fixedArrayType.ElementType.DumpReferenceTo(writer);
                writer.Write(" ");
                writer.Write(Name);
                writer.Write("[").Write(fixedArrayType.Size.ToString(CultureInfo.InvariantCulture)).Write("]");
            }
            else
            {
                FieldType?.DumpReferenceTo(writer);
                writer.Write(" ");
                writer.Write(Name);
            }

            if (InitValue != null)
            {
                writer.Write(" = ");
                writer.Write(InitValue);
            }
            writer.Write(";");
            writer.WriteLine();
        }
Exemplo n.º 2
0
        public override void DumpTo(CodeWriter writer)
        {
            var mode = writer.Mode;

            if (mode == CodeWriterMode.Full)
            {
                Comment?.DumpTo(writer);
            }
            this.DumpAttributesTo(writer);
            Visibility.DumpTo(writer);
            Modifiers.DumpTo(writer);
            ReturnType?.DumpReferenceTo(writer);
            writer.Write(" ");
            writer.Write(Name);

            if (GetBody == null && SetBody == null)
            {
                writer.Write(" { get; set; }");
                writer.WriteLine();
            }
            else
            {
                if (mode == CodeWriterMode.Simple)
                {
                    writer.Write(" { get {...} set {...} }");
                    writer.WriteLine();
                }
                else
                {
                    writer.WriteLine();
                    writer.OpenBraceBlock();
                    {
                        if (GetBody != null)
                        {
                            writer.WriteLine("get");
                            writer.OpenBraceBlock();
                            GetBody(writer, this);
                            writer.CloseBraceBlock();
                        }
                        if (SetBody != null)
                        {
                            writer.WriteLine("set");
                            writer.OpenBraceBlock();
                            SetBody(writer, this);
                            writer.CloseBraceBlock();
                        }
                    }
                    writer.CloseBraceBlock();
                }
            }
        }
Exemplo n.º 3
0
 public override void DumpTo(CodeWriter writer)
 {
     if (writer.Mode == CodeWriterMode.Full)
     {
         Comment?.DumpTo(writer);
     }
     this.DumpAttributesTo(writer);
     ReturnType?.DumpContextualAttributesTo(writer, false, CSharpAttributeScope.Return);
     Visibility.DumpTo(writer);
     writer.Write("delegate ");
     ReturnType?.DumpReferenceTo(writer);
     writer.Write(" ");
     writer.Write(Name);
     Parameters.DumpTo(writer);
     writer.Write(";");
     writer.WriteLine();
 }
Exemplo n.º 4
0
        public override void DumpTo(CodeWriter writer)
        {
            var mode = writer.Mode;

            if (mode == CodeWriterMode.Full)
            {
                Comment?.DumpTo(writer);
            }
            this.DumpAttributesTo(writer);
            Visibility.DumpTo(writer);
            Modifiers.DumpTo(writer);

            writer.Write(DeclarationKind);
            writer.Write(" ");

            writer.Write(Name);

            if (BaseTypes.Count > 0)
            {
                writer.Write(" : ");
                for (var i = 0; i < BaseTypes.Count; i++)
                {
                    var baseType = BaseTypes[i];
                    if (i > 0)
                    {
                        writer.Write(", ");
                    }
                    baseType.DumpReferenceTo(writer);
                }
            }
            writer.WriteLine();

            if (mode == CodeWriterMode.Full)
            {
                writer.OpenBraceBlock();
                {
                    this.DumpMembersTo(writer);
                }
                writer.CloseBraceBlock();
            }
            else
            {
                writer.WriteLine(" { ... }");
            }
        }
Exemplo n.º 5
0
        /// <inheritdoc />
        public override void DumpTo(CodeWriter writer)
        {
            var mode = writer.Mode;

            if (mode == CodeWriterMode.Full)
            {
                Comment?.DumpTo(writer);
            }
            this.DumpAttributesTo(writer);
            ReturnType?.DumpContextualAttributesTo(writer, false, CSharpAttributeScope.Return);
            Visibility.DumpTo(writer);
            Modifiers.DumpTo(writer);
            if (IsConstructor)
            {
                writer.Write((Parent as CSharpNamedType)?.Name);
            }
            else
            {
                ReturnType?.DumpReferenceTo(writer);
                writer.Write(" ");
                writer.Write(Name);
            }
            Parameters.DumpTo(writer);

            if (Body != null)
            {
                if (mode == CodeWriterMode.Full)
                {
                    writer.WriteLine();
                    writer.OpenBraceBlock();
                    Body?.Invoke(writer, this);
                    writer.CloseBraceBlock();
                }
                else
                {
                    writer.WriteLine(" { ... }");
                }
            }
            else
            {
                writer.WriteLine(";");
            }
        }