Compute Engine v1 API - Class ComputeEnumHelpers (2.4.0)

public static class ComputeEnumHelpers

Reference documentation and code samples for the Compute Engine v1 API class ComputeEnumHelpers.

Helper methods for conversion between the enums within the Compute API and the string representations used on the wire.

Inheritance

Object > ComputeEnumHelpers

Namespace

Google.Cloud.Compute.V1

Assembly

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

The value to convert.

Returns
TypeDescription
String

The string representation of the enum value.

Type Parameter
NameDescription
TEnum

The enum type to convert to a string.

Exceptions
TypeDescription
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
NameDescription
valueString

The text value to parse.

Returns
TypeDescription
TEnum

The parsed value.

Type Parameter
NameDescription
TEnum

The enum type to convert value to.

Exceptions
TypeDescription
ArgumentException

value is not a valid wire value for TEnum.

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

The text value to parse.

resultTEnum

The output parameter to store the result in. This will be the parsed value of TEnum if the return value is true, or the default value otherwise.

Returns
TypeDescription
Boolean

true if the value was successfully parsed; false otherwise

Type Parameter
NameDescription
TEnum

The enum type to convert value to.