IFieldAccessor.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 {
  8. /// <summary>
  9. /// Indicates whether the specified message contains the field.
  10. /// </summary>
  11. bool Has(IMessage message);
  12. /// <summary>
  13. /// Gets the count of the repeated field in the specified message.
  14. /// </summary>
  15. int GetRepeatedCount(IMessage message);
  16. /// <summary>
  17. /// Clears the field in the specified builder.
  18. /// </summary>
  19. /// <param name="builder"></param>
  20. void Clear(IBuilder builder);
  21. /// <summary>
  22. /// Creates a builder for the type of this field (which must be a message field).
  23. /// </summary>
  24. IBuilder CreateBuilder();
  25. /// <summary>
  26. /// Accessor for single fields
  27. /// </summary>
  28. object GetValue(IMessage message);
  29. /// <summary>
  30. /// Mutator for single fields
  31. /// </summary>
  32. void SetValue(IBuilder builder, object value);
  33. /// <summary>
  34. /// Accessor for repeated fields
  35. /// </summary>
  36. object GetRepeatedValue(IMessage message, int index);
  37. /// <summary>
  38. /// Mutator for repeated fields
  39. /// </summary>
  40. void SetRepeated(IBuilder builder, int index, object value);
  41. /// <summary>
  42. /// Adds the specified value to the field in the given builder.
  43. /// </summary>
  44. void AddRepeated(IBuilder builder, object value);
  45. /// <summary>
  46. /// Returns a read-only wrapper around the value of a repeated field.
  47. /// </summary>
  48. object GetRepeatedWrapper(IBuilder builder);
  49. }
  50. }