• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #region Copyright notice and license
2 // Protocol Buffers - Google's data interchange format
3 // Copyright 2008 Google Inc.  All rights reserved.
4 //
5 // Use of this source code is governed by a BSD-style
6 // license that can be found in the LICENSE file or at
7 // https://developers.google.com/open-source/licenses/bsd
8 #endregion
9 
10 using System;
11 using System.Collections;
12 
13 namespace Google.Protobuf.Reflection
14 {
15     /// <summary>
16     /// Allows fields to be reflectively accessed.
17     /// </summary>
18     public interface IFieldAccessor
19     {
20         /// <summary>
21         /// Returns the descriptor associated with this field.
22         /// </summary>
23         FieldDescriptor Descriptor { get; }
24 
25         /// <summary>
26         /// Clears the field in the specified message. (For repeated fields,
27         /// this clears the list.)
28         /// </summary>
Clear(IMessage message)29         void Clear(IMessage message);
30 
31         /// <summary>
32         /// Fetches the field value. For repeated values, this will be an
33         /// <see cref="IList"/> implementation. For map values, this will be an
34         /// <see cref="IDictionary"/> implementation.
35         /// </summary>
GetValue(IMessage message)36         object GetValue(IMessage message);
37 
38         /// <summary>
39         /// Indicates whether the field in the specified message is set.
40         /// For proto3 fields that aren't explicitly optional, this throws an <see cref="InvalidOperationException"/>
41         /// </summary>
HasValue(IMessage message)42         bool HasValue(IMessage message);
43 
44         /// <summary>
45         /// Mutator for single "simple" fields only.
46         /// </summary>
47         /// <remarks>
48         /// Repeated fields are mutated by fetching the value and manipulating it as a list.
49         /// Map fields are mutated by fetching the value and manipulating it as a dictionary.
50         /// </remarks>
51         /// <exception cref="InvalidOperationException">The field is not a "simple" field.</exception>
SetValue(IMessage message, object value)52         void SetValue(IMessage message, object value);
53     }
54 }