DescriptorBase.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using Google.ProtocolBuffers.DescriptorProtos;
  5. namespace Google.ProtocolBuffers.Descriptors {
  6. /// <summary>
  7. /// Base class for all descriptors, providing common functionality.
  8. /// </summary>
  9. /// <typeparam name="TProto">Type of the protocol buffer form of this descriptor</typeparam>
  10. /// <typeparam name="TOptions">Type of the options protocol buffer for this descriptor</typeparam>
  11. public abstract class DescriptorBase<TProto, TOptions> where TProto : IMessage<TProto>, IDescriptorProto<TOptions> {
  12. private readonly TProto proto;
  13. private readonly FileDescriptor file;
  14. protected DescriptorBase(TProto proto, FileDescriptor file) {
  15. this.proto = proto;
  16. this.file = file;
  17. }
  18. /// <summary>
  19. /// Returns the protocol buffer form of this descriptor
  20. /// </summary>
  21. public TProto Proto {
  22. get { return proto; }
  23. }
  24. public TOptions Options {
  25. get { return proto.Options; }
  26. }
  27. /// <summary>
  28. /// The fully qualified name of the descriptor's target.
  29. /// </summary>
  30. public string FullName {
  31. get { return proto.FullName; }
  32. }
  33. /// <summary>
  34. /// The brief name of the descriptor's target.
  35. /// </summary>
  36. public string Name {
  37. get { return proto.Name; }
  38. }
  39. /// <value>
  40. /// The file this descriptor was declared in.
  41. /// </value>
  42. public FileDescriptor File {
  43. get { return file; }
  44. }
  45. }
  46. }