DescriptorBase.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. /// TODO(jonskeet): Implement!
  30. /// </summary>
  31. public string FullName {
  32. get { return null; }
  33. }
  34. /// <summary>
  35. /// The brief name of the descriptor's target.
  36. /// </summary>
  37. public string Name {
  38. get { return proto.Name; }
  39. }
  40. /// <value>
  41. /// The file this descriptor was declared in.
  42. /// </value>
  43. public FileDescriptor File {
  44. get { return file; }
  45. }
  46. }
  47. }