public sealed class CustomOptions : object
Container for a set of custom options specified within a message, field etc.
Namespace
Google.Protobuf.ReflectionAssembly
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 | |
---|---|
Name | Description |
field | Int32 The field to fetch the value for. |
value | Boolean The output variable to populate. |
Returns | |
---|---|
Type | Description |
Boolean |
|
TryGetBytes(Int32, out ByteString)
public bool TryGetBytes(int field, out ByteString value)
Retrieves a bytes value for the specified option field.
Parameters | |
---|---|
Name | Description |
field | Int32 The field to fetch the value for. |
value | ByteString The output variable to populate. |
Returns | |
---|---|
Type | Description |
Boolean |
|
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 | |
---|---|
Name | Description |
field | Int32 The field to fetch the value for. |
value | Double The output variable to populate. |
Returns | |
---|---|
Type | Description |
Boolean |
|
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 | |
---|---|
Name | Description |
field | Int32 The field to fetch the value for. |
value | UInt32 The output variable to populate. |
Returns | |
---|---|
Type | Description |
Boolean |
|
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 | |
---|---|
Name | Description |
field | Int32 The field to fetch the value for. |
value | UInt64 The output variable to populate. |
Returns | |
---|---|
Type | Description |
Boolean |
|
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 | |
---|---|
Name | Description |
field | Int32 The field to fetch the value for. |
value | Single The output variable to populate. |
Returns | |
---|---|
Type | Description |
Boolean |
|
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 | |
---|---|
Name | Description |
field | Int32 The field to fetch the value for. |
value | Int32 The output variable to populate. |
Returns | |
---|---|
Type | Description |
Boolean |
|
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 | |
---|---|
Name | Description |
field | Int32 The field to fetch the value for. |
value | Int64 The output variable to populate. |
Returns | |
---|---|
Type | Description |
Boolean |
|
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 | |
---|---|
Name | Description |
field | Int32 The field to fetch the value for. |
value | T The output variable to populate. |
Returns | |
---|---|
Type | Description |
Boolean |
|
Type Parameter | |
---|---|
Name | Description |
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 | |
---|---|
Name | Description |
field | Int32 The field to fetch the value for. |
value | Int32 The output variable to populate. |
Returns | |
---|---|
Type | Description |
Boolean |
|
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 | |
---|---|
Name | Description |
field | Int32 The field to fetch the value for. |
value | Int64 The output variable to populate. |
Returns | |
---|---|
Type | Description |
Boolean |
|
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 | |
---|---|
Name | Description |
field | Int32 The field to fetch the value for. |
value | Int32 The output variable to populate. |
Returns | |
---|---|
Type | Description |
Boolean |
|
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 | |
---|---|
Name | Description |
field | Int32 The field to fetch the value for. |
value | Int64 The output variable to populate. |
Returns | |
---|---|
Type | Description |
Boolean |
|
TryGetString(Int32, out String)
public bool TryGetString(int field, out string value)
Retrieves a string value for the specified option field.
Parameters | |
---|---|
Name | Description |
field | Int32 The field to fetch the value for. |
value | String The output variable to populate. |
Returns | |
---|---|
Type | Description |
Boolean |
|
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 | |
---|---|
Name | Description |
field | Int32 The field to fetch the value for. |
value | UInt32 The output variable to populate. |
Returns | |
---|---|
Type | Description |
Boolean |
|
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 | |
---|---|
Name | Description |
field | Int32 The field to fetch the value for. |
value | UInt64 The output variable to populate. |
Returns | |
---|---|
Type | Description |
Boolean |
|