FileDescriptor.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using System;
  2. using Google.ProtocolBuffers.DescriptorProtos;
  3. using System.Collections.Generic;
  4. namespace Google.ProtocolBuffers.Descriptors {
  5. public class FileDescriptor : DescriptorBase<FileDescriptorProto, FileOptions> {
  6. private readonly IList<MessageDescriptor> messageTypes;
  7. private readonly IList<EnumDescriptor> enumTypes;
  8. private readonly IList<ServiceDescriptor> services;
  9. private readonly IList<FieldDescriptor> extensions;
  10. private readonly IList<FileDescriptor> dependencies;
  11. private readonly DescriptorPool pool;
  12. public FileDescriptor(FileDescriptorProto proto, FileDescriptor file) : base(proto, file) {
  13. }
  14. /// <summary>
  15. /// The package as declared in the .proto file. This may or may not
  16. /// be equivalent to the .NET namespace of the generated classes.
  17. /// </summary>
  18. public string Package {
  19. get { return Proto.Package; }
  20. }
  21. /// <value>
  22. /// Unmodifiable list of top-level message types declared in this file.
  23. /// </value>
  24. public IList<MessageDescriptor> MessageTypes {
  25. get { return messageTypes; }
  26. }
  27. /// <value>
  28. /// Unmodifiable list of top-level enum types declared in this file.
  29. /// </value>
  30. public IList<EnumDescriptor> EnumTypes {
  31. get { return enumTypes; }
  32. }
  33. /// <value>
  34. /// Unmodifiable list of top-level services declared in this file.
  35. /// </value>
  36. public IList<ServiceDescriptor> Services {
  37. get { return services; }
  38. }
  39. /// <value>
  40. /// Unmodifiable list of top-level extensions declared in this file.
  41. /// </value>
  42. public IList<FieldDescriptor> Extensions {
  43. get { return extensions; }
  44. }
  45. /// <value>
  46. /// Unmodifiable list of this file's dependencies (imports).
  47. /// </value>
  48. public IList<FileDescriptor> Dependencies {
  49. get { return dependencies; }
  50. }
  51. public static FileDescriptor BuildFrom(FileDescriptorProto proto,
  52. FileDescriptor[] dependencies) {
  53. throw new NotImplementedException();
  54. }
  55. /// <summary>
  56. /// This method is to be called by generated code only. It is equivalent
  57. /// to BuilderFrom except that the FileDescriptorProto is encoded in
  58. /// protocol buffer wire format.
  59. /// </summary>
  60. public static FileDescriptor InternalBuildGeneratedFileFrom(byte[] descriptorData,
  61. FileDescriptor[] dependencies) {
  62. FileDescriptorProto proto = FileDescriptorProto.ParseFrom(descriptorData);
  63. return BuildFrom(proto, dependencies);
  64. }
  65. }
  66. }