Class CustomOptions (3.15.8)

public sealed class CustomOptions : object

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(Int32, out Int32) 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(Int32, out Boolean)

public bool TryGetBool(int field, out bool value)

Retrieves a Boolean value for the specified option field.

Parameters
NameDescription
fieldInt32

The field to fetch the value for.

valueBoolean

The output variable to populate.

Returns
TypeDescription
Boolean

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

TryGetBytes(Int32, out ByteString)

public bool TryGetBytes(int field, out ByteString value)

Retrieves a bytes value for the specified option field.

Parameters
NameDescription
fieldInt32

The field to fetch the value for.

valueByteString

The output variable to populate.

Returns
TypeDescription
Boolean

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

TryGetDouble(Int32, out Double)

public bool TryGetDouble(int field, out double value)

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

Parameters
NameDescription
fieldInt32

The field to fetch the value for.

valueDouble

The output variable to populate.

Returns
TypeDescription
Boolean

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

TryGetFixed32(Int32, out UInt32)

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
NameDescription
fieldInt32

The field to fetch the value for.

valueUInt32

The output variable to populate.

Returns
TypeDescription
Boolean

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

TryGetFixed64(Int32, out UInt64)

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
NameDescription
fieldInt32

The field to fetch the value for.

valueUInt64

The output variable to populate.

Returns
TypeDescription
Boolean

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

TryGetFloat(Int32, out Single)

public bool TryGetFloat(int field, out float value)

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

Parameters
NameDescription
fieldInt32

The field to fetch the value for.

valueSingle

The output variable to populate.

Returns
TypeDescription
Boolean

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

TryGetInt32(Int32, out Int32)

public bool TryGetInt32(int field, out int value)

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

Parameters
NameDescription
fieldInt32

The field to fetch the value for.

valueInt32

The output variable to populate.

Returns
TypeDescription
Boolean

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

TryGetInt64(Int32, out Int64)

public bool TryGetInt64(int field, out long value)

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

Parameters
NameDescription
fieldInt32

The field to fetch the value for.

valueInt64

The output variable to populate.

Returns
TypeDescription
Boolean

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

TryGetMessage<T>(Int32, 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
NameDescription
fieldInt32

The field to fetch the value for.

valueT

The output variable to populate.

Returns
TypeDescription
Boolean

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

Type Parameter
NameDescription
T

TryGetSFixed32(Int32, out Int32)

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
NameDescription
fieldInt32

The field to fetch the value for.

valueInt32

The output variable to populate.

Returns
TypeDescription
Boolean

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

TryGetSFixed64(Int32, out Int64)

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
NameDescription
fieldInt32

The field to fetch the value for.

valueInt64

The output variable to populate.

Returns
TypeDescription
Boolean

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

TryGetSInt32(Int32, out Int32)

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
NameDescription
fieldInt32

The field to fetch the value for.

valueInt32

The output variable to populate.

Returns
TypeDescription
Boolean

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

TryGetSInt64(Int32, out Int64)

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
NameDescription
fieldInt32

The field to fetch the value for.

valueInt64

The output variable to populate.

Returns
TypeDescription
Boolean

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

TryGetString(Int32, out String)

public bool TryGetString(int field, out string value)

Retrieves a string value for the specified option field.

Parameters
NameDescription
fieldInt32

The field to fetch the value for.

valueString

The output variable to populate.

Returns
TypeDescription
Boolean

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

TryGetUInt32(Int32, out UInt32)

public bool TryGetUInt32(int field, out uint value)

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

Parameters
NameDescription
fieldInt32

The field to fetch the value for.

valueUInt32

The output variable to populate.

Returns
TypeDescription
Boolean

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

TryGetUInt64(Int32, out UInt64)

public bool TryGetUInt64(int field, out ulong value)

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

Parameters
NameDescription
fieldInt32

The field to fetch the value for.

valueUInt64

The output variable to populate.

Returns
TypeDescription
Boolean

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