public void Generate(SourceWriter writer) { writer.WriteModifiers(this.Modifiers); writer.Write($"{this.Type} {this.Name}"); if (this.IsAutoProperty()) { writer.Write(" { "); if (this.GetModifiers.HasValue) { writer.WriteModifiers(this.GetModifiers.Value); } writer.Write("get;"); if (!this.IsReadOnly) { if (this.SetModifiers.HasValue) { writer.WriteModifiers(this.SetModifiers.Value); } writer.Write("set;"); } writer.Write(" } "); } else { writer.WriteLine(); writer.StartScope(); if (this.Getter.HasValue) { if (this.GetModifiers.HasValue) { writer.WriteModifiers(this.GetModifiers.Value); } writer.WriteLine("get"); writer.StartScope(); this.Getter.Value.Generate(writer); writer.EndScope(); } if (this.Setter.HasValue) { if (this.SetModifiers.HasValue) { writer.WriteModifiers(this.SetModifiers.Value); } writer.WriteLine("set"); writer.StartScope(); this.Setter.Value.Generate(writer); writer.EndScope(); } writer.EndScope(); } }
public void Generate(SourceWriter writer) { writer.WriteModifiers(this.Modifiers); writer.Write($"{this.Class}"); this.Parameters.Generate(writer); if (this.Chain.HasValue) { writer.StartIndent(); writer.WriteLine(); this.Chain.Value.Generate(writer); writer.EndIndent(); } writer.WriteLine(); writer.StartScope(); this.Body.Generate(writer); writer.EndScope(); }
public void Generate(SourceWriter writer) { writer.WriteModifiers(this.Modifiers); writer.WriteLine($"class {this.Name}"); if (this.InheritsFrom.Count > 0) { writer.StartIndent(); writer.Write(": "); writer.Write(string.Join(", ", this.InheritsFrom)); writer.EndIndent(); writer.WriteLine(); } writer.StartScope(); foreach (var field in this.Fields) { field.Generate(writer); } writer.ConditionalEmptyLine(this.Fields.Count > 0); foreach (var constructor in this.Constructors) { constructor.Generate(writer); writer.WriteLine(); } foreach (var property in this.Properties) { property.Generate(writer); writer.WriteLine(); } foreach (var method in this.Methods) { method.Generate(writer); writer.WriteLine(); } writer.EndScope(); }