SourceFileGenerator.cs 930 B

1234567891011121314151617181920212223242526272829
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Text;
  5. using Google.ProtocolBuffers.Descriptors;
  6. namespace Google.ProtocolBuffers.ProtoGen {
  7. /// <summary>
  8. /// Generator to hold a TextGenerator, generate namespace aliases etc.
  9. /// Each source file created uses one of these, and it can be used to create
  10. /// multiple classes within the same file.
  11. /// </summary>
  12. internal class SourceFileGenerator {
  13. private readonly TextGenerator output;
  14. private SourceFileGenerator(TextWriter writer) {
  15. output = new TextGenerator(writer);
  16. }
  17. /// <summary>
  18. /// Creates a ClassFileGenerator for the given writer, which will be closed
  19. /// when the instance is disposed. The specified namespace is created, if it's non-null.
  20. /// </summary>
  21. internal static SourceFileGenerator ForWriter(TextWriter writer) {
  22. return new SourceFileGenerator(writer);
  23. }
  24. }
  25. }