IndexedDescriptorBase.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Protocol Buffers - Google's data interchange format
  2. // Copyright 2008 Google Inc.
  3. // http://code.google.com/p/protobuf/
  4. //
  5. // Licensed under the Apache License, Version 2.0 (the "License");
  6. // you may not use this file except in compliance with the License.
  7. // You may obtain a copy of the License at
  8. //
  9. // http://www.apache.org/licenses/LICENSE-2.0
  10. //
  11. // Unless required by applicable law or agreed to in writing, software
  12. // distributed under the License is distributed on an "AS IS" BASIS,
  13. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. // See the License for the specific language governing permissions and
  15. // limitations under the License.
  16. using Google.ProtocolBuffers.DescriptorProtos;
  17. namespace Google.ProtocolBuffers.Descriptors {
  18. /// <summary>
  19. /// Base class for descriptors which are also indexed. This is all of them other than
  20. /// <see cref="FileDescriptor" />.
  21. /// </summary>
  22. public abstract class IndexedDescriptorBase<TProto, TOptions> : DescriptorBase<TProto, TOptions>
  23. where TProto : IMessage<TProto>, IDescriptorProto<TOptions> {
  24. private readonly int index;
  25. protected IndexedDescriptorBase(TProto proto, FileDescriptor file, string fullName, int index)
  26. : base(proto, file, fullName) {
  27. this.index = index;
  28. }
  29. /// <value>
  30. /// The index of this descriptor within its parent descriptor.
  31. /// </value>
  32. /// <remarks>
  33. /// This returns the index of this descriptor within its parent, for
  34. /// this descriptor's type. (There can be duplicate values for different
  35. /// types, e.g. one enum type with index 0 and one message type with index 0.)
  36. /// </remarks>
  37. public int Index {
  38. get { return index; }
  39. }
  40. }
  41. }