Interface IFieldAccessor (3.23.0)

public interface IFieldAccessor

Allows fields to be reflectively accessed.

Namespace

Google.Protobuf.Reflection

Assembly

Google.Protobuf.dll

Properties

Descriptor

FieldDescriptor Descriptor { get; }

Returns the descriptor associated with this field.

Property Value
Type Description
FieldDescriptor

Methods

Clear(IMessage)

void Clear(IMessage message)

Clears the field in the specified message. (For repeated fields, this clears the list.)

Parameter
Name Description
message IMessage

GetValue(IMessage)

object GetValue(IMessage message)

Fetches the field value. For repeated values, this will be an IList implementation. For map values, this will be an IDictionary implementation.

Parameter
Name Description
message IMessage
Returns
Type Description
object

HasValue(IMessage)

bool HasValue(IMessage message)

Indicates whether the field in the specified message is set. For proto3 fields that aren't explicitly optional, this throws an InvalidOperationException

Parameter
Name Description
message IMessage
Returns
Type Description
bool

SetValue(IMessage, object)

void SetValue(IMessage message, object value)

Mutator for single "simple" fields only.

Parameters
Name Description
message IMessage
value object
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 Description
InvalidOperationException

The field is not a "simple" field.