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
TypeDescription
FieldDescriptor

Methods

Clear(IMessage)

void Clear(IMessage message)

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

Parameter
NameDescription
messageIMessage

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
NameDescription
messageIMessage
Returns
TypeDescription
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
NameDescription
messageIMessage
Returns
TypeDescription
bool

SetValue(IMessage, object)

void SetValue(IMessage message, object value)

Mutator for single "simple" fields only.

Parameters
NameDescription
messageIMessage
valueobject
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
TypeDescription
InvalidOperationException

The field is not a "simple" field.