Class CustomOptions (3.27.1)

public sealed class CustomOptions

Container for a set of custom options specified within a message, field etc.

Inheritance

object > CustomOptions

Namespace

Google.Protobuf.Reflection

Assembly

Google.Protobuf.dll

Remarks

This type is publicly immutable, but internally mutable. It is only populated by the descriptor parsing code - by the time any user code is able to see an instance, it will be fully initialized.

If an option is requested using the incorrect method, an answer may still be returned: all of the numeric types are represented internally using 64-bit integers, for example. It is up to the caller to ensure that they make the appropriate method call for the option they're interested in. Note that enum options are simply stored as integers, so the value should be fetched using TryGetInt32(int, out int) and then cast appropriately.

Repeated options are currently not supported. Asking for a single value of an option which was actually repeated will return the last value, except for message types where all the set values are merged together.

Methods

TryGetBool(int, out bool)

public bool TryGetBool(int field, out bool value)

Retrieves a Boolean value for the specified option field.

Parameters
Name Description
field int

The field to fetch the value for.

value bool

The output variable to populate.

Returns
Type Description
bool

true if a suitable value for the field was found; false otherwise.

TryGetBytes(int, out ByteString)

public bool TryGetBytes(int field, out ByteString value)

Retrieves a bytes value for the specified option field.

Parameters
Name Description
field int

The field to fetch the value for.

value ByteString

The output variable to populate.

Returns
Type Description
bool

true if a suitable value for the field was found; false otherwise.

TryGetDouble(int, out double)

public bool TryGetDouble(int field, out double value)

Retrieves a 64-bit floating point value for the specified option field.

Parameters
Name Description
field int

The field to fetch the value for.

value double

The output variable to populate.

Returns
Type Description
bool

true if a suitable value for the field was found; false otherwise.

TryGetFixed32(int, out uint)

public bool TryGetFixed32(int field, out uint value)

Retrieves an unsigned 32-bit integer value for the specified option field, assuming a fixed-length representation.

Parameters
Name Description
field int

The field to fetch the value for.

value uint

The output variable to populate.

Returns
Type Description
bool

true if a suitable value for the field was found; false otherwise.

TryGetFixed64(int, out ulong)

public bool TryGetFixed64(int field, out ulong value)

Retrieves an unsigned 64-bit integer value for the specified option field, assuming a fixed-length representation.

Parameters
Name Description
field int

The field to fetch the value for.

value ulong

The output variable to populate.

Returns
Type Description
bool

true if a suitable value for the field was found; false otherwise.

TryGetFloat(int, out float)

public bool TryGetFloat(int field, out float value)

Retrieves a 32-bit floating point value for the specified option field.

Parameters
Name Description
field int

The field to fetch the value for.

value float

The output variable to populate.

Returns
Type Description
bool

true if a suitable value for the field was found; false otherwise.

TryGetInt32(int, out int)

public bool TryGetInt32(int field, out int value)

Retrieves a signed 32-bit integer value for the specified option field.

Parameters
Name Description
field int

The field to fetch the value for.

value int

The output variable to populate.

Returns
Type Description
bool

true if a suitable value for the field was found; false otherwise.

TryGetInt64(int, out long)

public bool TryGetInt64(int field, out long value)

Retrieves a signed 64-bit integer value for the specified option field.

Parameters
Name Description
field int

The field to fetch the value for.

value long

The output variable to populate.

Returns
Type Description
bool

true if a suitable value for the field was found; false otherwise.

TryGetMessage<T>(int, out T)

public bool TryGetMessage<T>(int field, out T value) where T : class, IMessage, new()

Retrieves a message value for the specified option field.

Parameters
Name Description
field int

The field to fetch the value for.

value T

The output variable to populate.

Returns
Type Description
bool

true if a suitable value for the field was found; false otherwise.

Type Parameter
Name Description
T

TryGetSFixed32(int, out int)

public bool TryGetSFixed32(int field, out int value)

Retrieves a signed 32-bit integer value for the specified option field, assuming a fixed-length representation.

Parameters
Name Description
field int

The field to fetch the value for.

value int

The output variable to populate.

Returns
Type Description
bool

true if a suitable value for the field was found; false otherwise.

TryGetSFixed64(int, out long)

public bool TryGetSFixed64(int field, out long value)

Retrieves a signed 64-bit integer value for the specified option field, assuming a fixed-length representation.

Parameters
Name Description
field int

The field to fetch the value for.

value long

The output variable to populate.

Returns
Type Description
bool

true if a suitable value for the field was found; false otherwise.

TryGetSInt32(int, out int)

public bool TryGetSInt32(int field, out int value)

Retrieves a signed 32-bit integer value for the specified option field, assuming a zigzag encoding.

Parameters
Name Description
field int

The field to fetch the value for.

value int

The output variable to populate.

Returns
Type Description
bool

true if a suitable value for the field was found; false otherwise.

TryGetSInt64(int, out long)

public bool TryGetSInt64(int field, out long value)

Retrieves a signed 64-bit integer value for the specified option field, assuming a zigzag encoding.

Parameters
Name Description
field int

The field to fetch the value for.

value long

The output variable to populate.

Returns
Type Description
bool

true if a suitable value for the field was found; false otherwise.

TryGetString(int, out string)

public bool TryGetString(int field, out string value)

Retrieves a string value for the specified option field.

Parameters
Name Description
field int

The field to fetch the value for.

value string

The output variable to populate.

Returns
Type Description
bool

true if a suitable value for the field was found; false otherwise.

TryGetUInt32(int, out uint)

public bool TryGetUInt32(int field, out uint value)

Retrieves an unsigned 32-bit integer value for the specified option field.

Parameters
Name Description
field int

The field to fetch the value for.

value uint

The output variable to populate.

Returns
Type Description
bool

true if a suitable value for the field was found; false otherwise.

TryGetUInt64(int, out ulong)

public bool TryGetUInt64(int field, out ulong value)

Retrieves an unsigned 64-bit integer value for the specified option field.

Parameters
Name Description
field int

The field to fetch the value for.

value ulong

The output variable to populate.

Returns
Type Description
bool

true if a suitable value for the field was found; false otherwise.