IndexedDescriptorBase.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233
  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 descriptors which are also indexed. This is all of them other than
  8. /// <see cref="FileDescriptor" />.
  9. /// </summary>
  10. public abstract class IndexedDescriptorBase<TProto, TOptions> : DescriptorBase<TProto, TOptions>
  11. where TProto : IMessage<TProto>, IDescriptorProto<TOptions> {
  12. private readonly int index;
  13. protected IndexedDescriptorBase(TProto proto, FileDescriptor file, string fullName, int index)
  14. : base(proto, file, fullName) {
  15. this.index = index;
  16. }
  17. /// <value>
  18. /// The index of this descriptor within its parent descriptor.
  19. /// </value>
  20. /// <remarks>
  21. /// This returns the index of this descriptor within its parent, for
  22. /// this descriptor's type. (There can be duplicate values for different
  23. /// types, e.g. one enum type with index 0 and one message type with index 0.)
  24. /// </remarks>
  25. public int Index {
  26. get { return index; }
  27. }
  28. }
  29. }