public void WriteProperty(IndentStreamWriter writer) { this.WriteDocument(writer); var declare = new String[] { this.propertyAccess, this.propertyStatic, this.propertyType, this.propertyName, }; var declareLine = String.Join(" ", declare.Where(w => w != PropertyReader.Missed)); writer.WriteLineIndent(declareLine); using (new BraceWriter(writer)) { if (this.propertyGettable) { writer.WriteIndent(String.Empty); if (!String.IsNullOrWhiteSpace(this.propertyGetAccess)) { writer.Write("{0} ", this.propertyGetAccess); } writer.WriteLine("get"); using (new BraceWriter(writer)) { writer.WriteLineIndent(this.GetterTemplate, this.propertyCode); } } if (this.propertySettable) { writer.WriteIndent(String.Empty); if (!String.IsNullOrWhiteSpace(this.propertySetAccess)) { writer.Write("{0} ", this.propertySetAccess); } writer.WriteLine("set"); using (new BraceWriter(writer)) { writer.WriteLineIndent(this.SetterTemplate, this.propertyCode); } } } writer.WriteLine(); }
public void WriteHeader(IndentStreamWriter writer) { if (this._fullUsings.Count == 0) { writer.WriteLine("using System;"); } else { foreach (var @using in this._fullUsings.OrderBy(key => key)) { writer.WriteLine("using {0};", @using); } } writer.WriteLine(); writer.WriteLine("namespace {0}", this._namespace ?? this.Namespace); writer.WriteOpenBrace(); foreach (var @using in this._shortUsings.OrderBy(key => key)) { writer.WriteLineIndent("using {0};", @using); } writer.WriteLine(); writer.WriteIndent("public partial class {0}", this.ClassName); if (this._base != null) { writer.Write(" : {0}", this._base); } if (this._implements.Count != 0) { writer.Write(this._base == null ? " : {0}" : ", {0}", String.Join(", ", this._implements)); } writer.WriteLine(); writer.WriteOpenBrace(); }
private void WriteDocument(IndentStreamWriter writer) { if (String.IsNullOrWhiteSpace(this.Document)) { return; } writer.WriteLineIndent("/// <summary>"); using (var docReader = new StringReader(this.Document)) { while (true) { var line = docReader.ReadLine(); if (line == null) { break; } writer.WriteLineIndent("/// {0}", line); } } writer.WriteLineIndent("/// </summary>"); }