IFieldAccessor.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. namespace Google.ProtocolBuffers.FieldAccess {
  17. /// <summary>
  18. /// Allows fields to be reflectively accessed in a smart manner.
  19. /// The property descriptors for each field are created once and then cached.
  20. /// In addition, this interface holds knowledge of repeated fields, builders etc.
  21. /// </summary>
  22. internal interface IFieldAccessor {
  23. /// <summary>
  24. /// Indicates whether the specified message contains the field.
  25. /// </summary>
  26. bool Has(IMessage message);
  27. /// <summary>
  28. /// Gets the count of the repeated field in the specified message.
  29. /// </summary>
  30. int GetRepeatedCount(IMessage message);
  31. /// <summary>
  32. /// Clears the field in the specified builder.
  33. /// </summary>
  34. /// <param name="builder"></param>
  35. void Clear(IBuilder builder);
  36. /// <summary>
  37. /// Creates a builder for the type of this field (which must be a message field).
  38. /// </summary>
  39. IBuilder CreateBuilder();
  40. /// <summary>
  41. /// Accessor for single fields
  42. /// </summary>
  43. object GetValue(IMessage message);
  44. /// <summary>
  45. /// Mutator for single fields
  46. /// </summary>
  47. void SetValue(IBuilder builder, object value);
  48. /// <summary>
  49. /// Accessor for repeated fields
  50. /// </summary>
  51. object GetRepeatedValue(IMessage message, int index);
  52. /// <summary>
  53. /// Mutator for repeated fields
  54. /// </summary>
  55. void SetRepeated(IBuilder builder, int index, object value);
  56. /// <summary>
  57. /// Adds the specified value to the field in the given builder.
  58. /// </summary>
  59. void AddRepeated(IBuilder builder, object value);
  60. /// <summary>
  61. /// Returns a read-only wrapper around the value of a repeated field.
  62. /// </summary>
  63. object GetRepeatedWrapper(IBuilder builder);
  64. }
  65. }