Class CustomOptions
Container for a set of custom options specified within a message, field etc.
Inheritance
Inherited Members
Namespace: Google.Protobuf.Reflection
Assembly: Google.Protobuf.dll
Syntax
public sealed class CustomOptions
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)
Retrieves a Boolean value for the specified option field.
Declaration
public bool TryGetBool(int field, out bool value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | field | The field to fetch the value for. |
System.Boolean | value | The output variable to populate. |
Returns
Type | Description |
---|---|
System.Boolean |
|
TryGetBytes(Int32, out ByteString)
Retrieves a bytes value for the specified option field.
Declaration
public bool TryGetBytes(int field, out ByteString value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | field | The field to fetch the value for. |
ByteString | value | The output variable to populate. |
Returns
Type | Description |
---|---|
System.Boolean |
|
TryGetDouble(Int32, out Double)
Retrieves a 64-bit floating point value for the specified option field.
Declaration
public bool TryGetDouble(int field, out double value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | field | The field to fetch the value for. |
System.Double | value | The output variable to populate. |
Returns
Type | Description |
---|---|
System.Boolean |
|
TryGetFixed32(Int32, out UInt32)
Retrieves an unsigned 32-bit integer value for the specified option field, assuming a fixed-length representation.
Declaration
public bool TryGetFixed32(int field, out uint value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | field | The field to fetch the value for. |
System.UInt32 | value | The output variable to populate. |
Returns
Type | Description |
---|---|
System.Boolean |
|
TryGetFixed64(Int32, out UInt64)
Retrieves an unsigned 64-bit integer value for the specified option field, assuming a fixed-length representation.
Declaration
public bool TryGetFixed64(int field, out ulong value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | field | The field to fetch the value for. |
System.UInt64 | value | The output variable to populate. |
Returns
Type | Description |
---|---|
System.Boolean |
|
TryGetFloat(Int32, out Single)
Retrieves a 32-bit floating point value for the specified option field.
Declaration
public bool TryGetFloat(int field, out float value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | field | The field to fetch the value for. |
System.Single | value | The output variable to populate. |
Returns
Type | Description |
---|---|
System.Boolean |
|
TryGetInt32(Int32, out Int32)
Retrieves a signed 32-bit integer value for the specified option field.
Declaration
public bool TryGetInt32(int field, out int value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | field | The field to fetch the value for. |
System.Int32 | value | The output variable to populate. |
Returns
Type | Description |
---|---|
System.Boolean |
|
TryGetInt64(Int32, out Int64)
Retrieves a signed 64-bit integer value for the specified option field.
Declaration
public bool TryGetInt64(int field, out long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | field | The field to fetch the value for. |
System.Int64 | value | The output variable to populate. |
Returns
Type | Description |
---|---|
System.Boolean |
|
TryGetMessage<T>(Int32, out T)
Retrieves a message value for the specified option field.
Declaration
public bool TryGetMessage<T>(int field, out T value)
where T : class, IMessage, new()
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | field | The field to fetch the value for. |
T | value | The output variable to populate. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Type Parameters
Name | Description |
---|---|
T |
TryGetSFixed32(Int32, out Int32)
Retrieves a signed 32-bit integer value for the specified option field, assuming a fixed-length representation.
Declaration
public bool TryGetSFixed32(int field, out int value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | field | The field to fetch the value for. |
System.Int32 | value | The output variable to populate. |
Returns
Type | Description |
---|---|
System.Boolean |
|
TryGetSFixed64(Int32, out Int64)
Retrieves a signed 64-bit integer value for the specified option field, assuming a fixed-length representation.
Declaration
public bool TryGetSFixed64(int field, out long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | field | The field to fetch the value for. |
System.Int64 | value | The output variable to populate. |
Returns
Type | Description |
---|---|
System.Boolean |
|
TryGetSInt32(Int32, out Int32)
Retrieves a signed 32-bit integer value for the specified option field, assuming a zigzag encoding.
Declaration
public bool TryGetSInt32(int field, out int value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | field | The field to fetch the value for. |
System.Int32 | value | The output variable to populate. |
Returns
Type | Description |
---|---|
System.Boolean |
|
TryGetSInt64(Int32, out Int64)
Retrieves a signed 64-bit integer value for the specified option field, assuming a zigzag encoding.
Declaration
public bool TryGetSInt64(int field, out long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | field | The field to fetch the value for. |
System.Int64 | value | The output variable to populate. |
Returns
Type | Description |
---|---|
System.Boolean |
|
TryGetString(Int32, out String)
Retrieves a string value for the specified option field.
Declaration
public bool TryGetString(int field, out string value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | field | The field to fetch the value for. |
System.String | value | The output variable to populate. |
Returns
Type | Description |
---|---|
System.Boolean |
|
TryGetUInt32(Int32, out UInt32)
Retrieves an unsigned 32-bit integer value for the specified option field.
Declaration
public bool TryGetUInt32(int field, out uint value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | field | The field to fetch the value for. |
System.UInt32 | value | The output variable to populate. |
Returns
Type | Description |
---|---|
System.Boolean |
|
TryGetUInt64(Int32, out UInt64)
Retrieves an unsigned 64-bit integer value for the specified option field.
Declaration
public bool TryGetUInt64(int field, out ulong value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | field | The field to fetch the value for. |
System.UInt64 | value | The output variable to populate. |
Returns
Type | Description |
---|---|
System.Boolean |
|