Interface IFieldAccessor
Allows fields to be reflectively accessed.
Namespace: Google.Protobuf.Reflection
Assembly: Google.Protobuf.dll
Syntax
public interface IFieldAccessor
Properties
Descriptor
Returns the descriptor associated with this field.
Declaration
FieldDescriptor Descriptor { get; }
Property Value
Type | Description |
---|---|
FieldDescriptor |
Methods
Clear(IMessage)
Clears the field in the specified message. (For repeated fields, this clears the list.)
Declaration
void Clear(IMessage message)
Parameters
Type | Name | Description |
---|---|---|
IMessage | message |
GetValue(IMessage)
Fetches the field value. For repeated values, this will be an System.Collections.IList implementation. For map values, this will be an System.Collections.IDictionary implementation.
Declaration
object GetValue(IMessage message)
Parameters
Type | Name | Description |
---|---|---|
IMessage | message |
Returns
Type | Description |
---|---|
System.Object |
HasValue(IMessage)
Indicates whether the field in the specified message is set. For proto3 fields, this throws an System.InvalidOperationException
Declaration
bool HasValue(IMessage message)
Parameters
Type | Name | Description |
---|---|---|
IMessage | message |
Returns
Type | Description |
---|---|
System.Boolean |
SetValue(IMessage, Object)
Mutator for single "simple" fields only.
Declaration
void SetValue(IMessage message, object value)
Parameters
Type | Name | Description |
---|---|---|
IMessage | message | |
System.Object | value |
Remarks
Repeated fields are mutated by fetching the value and manipulating it as a list. Map fields are mutated by fetching the value and manipulating it as a dictionary.
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | The field is not a "simple" field. |