IFieldAccessor.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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<TMessage, TBuilder>
  23. where TMessage : IMessage<TMessage, TBuilder>
  24. where TBuilder : IBuilder<TMessage, TBuilder> {
  25. /// <summary>
  26. /// Indicates whether the specified message contains the field.
  27. /// </summary>
  28. bool Has(TMessage message);
  29. /// <summary>
  30. /// Gets the count of the repeated field in the specified message.
  31. /// </summary>
  32. int GetRepeatedCount(TMessage message);
  33. /// <summary>
  34. /// Clears the field in the specified builder.
  35. /// </summary>
  36. /// <param name="builder"></param>
  37. void Clear(TBuilder builder);
  38. /// <summary>
  39. /// Creates a builder for the type of this field (which must be a message field).
  40. /// </summary>
  41. IBuilder CreateBuilder();
  42. /// <summary>
  43. /// Accessor for single fields
  44. /// </summary>
  45. object GetValue(TMessage message);
  46. /// <summary>
  47. /// Mutator for single fields
  48. /// </summary>
  49. void SetValue(TBuilder builder, object value);
  50. /// <summary>
  51. /// Accessor for repeated fields
  52. /// </summary>
  53. object GetRepeatedValue(IMessage message, int index);
  54. /// <summary>
  55. /// Mutator for repeated fields
  56. /// </summary>
  57. void SetRepeated(IBuilder builder, int index, object value);
  58. /// <summary>
  59. /// Adds the specified value to the field in the given builder.
  60. /// </summary>
  61. void AddRepeated(IBuilder builder, object value);
  62. /// <summary>
  63. /// Returns a read-only wrapper around the value of a repeated field.
  64. /// </summary>
  65. object GetRepeatedWrapper(IBuilder builder);
  66. }
  67. }