IFieldAccessor.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. namespace Google.ProtocolBuffers.FieldAccess {
  2. /// <summary>
  3. /// Allows fields to be reflectively accessed in a smart manner.
  4. /// The property descriptors for each field are created once and then cached.
  5. /// In addition, this interface holds knowledge of repeated fields, builders etc.
  6. /// </summary>
  7. internal interface IFieldAccessor<TMessage, TBuilder>
  8. where TMessage : IMessage<TMessage>
  9. where TBuilder : IBuilder<TMessage> {
  10. /// <summary>
  11. /// Indicates whether the specified message contains the field.
  12. /// </summary>
  13. bool Has(IMessage<TMessage> message);
  14. /// <summary>
  15. /// Gets the count of the repeated field in the specified message.
  16. /// </summary>
  17. int GetRepeatedCount(IMessage<TMessage> message);
  18. /// <summary>
  19. /// Clears the field in the specified builder.
  20. /// </summary>
  21. /// <param name="builder"></param>
  22. void Clear(IBuilder<TMessage> builder);
  23. /// <summary>
  24. /// Creates a builder for the type of this field (which must be a message field).
  25. /// </summary>
  26. IBuilder CreateBuilder();
  27. /// <summary>
  28. /// Accessor for single fields
  29. /// </summary>
  30. object GetValue(IMessage<TMessage> message);
  31. /// <summary>
  32. /// Mutator for single fields
  33. /// </summary>
  34. void SetValue(IBuilder<TMessage> builder, object value);
  35. /// <summary>
  36. /// Accessor for repeated fields
  37. /// </summary>
  38. object GetRepeatedValue(IMessage<TMessage> message, int index);
  39. /// <summary>
  40. /// Mutator for repeated fields
  41. /// </summary>
  42. void SetRepeated(IBuilder<TMessage> builder, int index, object value);
  43. /// <summary>
  44. /// Adds the specified value to the field in the given builder.
  45. /// </summary>
  46. void AddRepeated(IBuilder<TMessage> builder, object value);
  47. /// <summary>
  48. /// Returns a read-only wrapper around the value of a repeated field.
  49. /// </summary>
  50. object GetRepeatedWrapper(IBuilder<TMessage> builder);
  51. }
  52. }