public void Write(ISourceWriter writer) { // We MUST generate the methods first, because during the writing of a method // it is possible it will find injected / static fields that are added to // this type that need to be written out below var methodWriter = new SourceWriter(); foreach (var method in this._methods) { methodWriter.BlankLine(); method.WriteMethod(methodWriter); } this.WriteDeclaration(writer); if (this.AllStaticFields.Any()) { this.WriteFieldDeclarations(writer, this.AllStaticFields); } if (this.AllInjectedFields.Any()) { this.WriteFieldDeclarations(writer, this.AllInjectedFields); this.WriteConstructorMethod(writer, this.AllInjectedFields); } writer.WriteLines(methodWriter.Code()); writer.FinishBlock(); }