public static class ComputeEnumHelpers
Helper methods for conversion between the enums within the Compute API and the string representations used on the wire.
Namespace
Google.Cloud.Compute.V1Assembly
Google.Cloud.Compute.V1.dll
Methods
Format<TEnum>(TEnum)
public static string Format<TEnum>(TEnum value)
where TEnum : struct, Enum
Converts the given enum value into the wire representation as a string.
Parameter | |
---|---|
Name | Description |
value | TEnum The value to convert. |
Returns | |
---|---|
Type | Description |
String | The string representation of the enum value. |
Type Parameter | |
---|---|
Name | Description |
TEnum | The enum type to convert to a string. |
Exceptions | |
---|---|
Type | Description |
ArgumentException | The enum value is not defined, so it has no known wire representation. |
Parse<TEnum>(String)
public static TEnum Parse<TEnum>(string value)
where TEnum : struct, Enum
Parses the given string value as the wire representation of a
TEnum
value, throwing an exception if the value cannot be parsed.
Parameter | |
---|---|
Name | Description |
value | String The text value to parse. |
Returns | |
---|---|
Type | Description |
TEnum | The parsed value. |
Type Parameter | |
---|---|
Name | Description |
TEnum | The enum type to convert |
Exceptions | |
---|---|
Type | Description |
ArgumentException |
|
TryParse<TEnum>(String, out TEnum)
public static bool TryParse<TEnum>(string value, out TEnum result)
where TEnum : struct, Enum
Attempts to parse the given string value as the wire representation of
a TEnum
value.
Parameters | |
---|---|
Name | Description |
value | String The text value to parse. |
result | TEnum The output parameter to store the result in. This will be the
parsed value of |
Returns | |
---|---|
Type | Description |
Boolean | true if the value was successfully parsed; false otherwise |
Type Parameter | |
---|---|
Name | Description |
TEnum | The enum type to convert |