Show / Hide Table of Contents

Class LocationName

Resource name for the 'location' resource which is widespread across Google Cloud Platform. While most resource names are generated on a per-API basis, many APIs use a location resource, and it's useful to be able to pass values from one API to another.

Inheritance
System.Object
LocationName
Implements
IResourceName
System.IEquatable<LocationName>
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: Google.Api.Gax.ResourceNames
Assembly: Google.Api.Gax.dll
Syntax
public sealed class LocationName : IResourceName, IEquatable<LocationName>

Constructors

LocationName(String, String)

Constructs a new instance of a LocationName class from the component parts of pattern projects/{project}/locations/{location}

Declaration
public LocationName(string projectId, string locationId)
Parameters
Type Name Description
System.String projectId

The Project ID. Must not be null or empty.

System.String locationId

The Location ID. Must not be null or empty.

Properties

IsKnownPattern

Whether this instance contains a resource name with a known pattern.

Declaration
public bool IsKnownPattern { get; }
Property Value
Type Description
System.Boolean
Implements
IResourceName.IsKnownPattern

LocationId

The Location ID. Will not be null, unless this instance contains an unparsed resource name.

Declaration
public string LocationId { get; }
Property Value
Type Description
System.String

ProjectId

The Project ID. Will not be null, unless this instance contains an unparsed resource name.

Declaration
public string ProjectId { get; }
Property Value
Type Description
System.String

Type

The LocationName.ResourceNameType of the contained resource name.

Declaration
public LocationName.ResourceNameType Type { get; }
Property Value
Type Description
LocationName.ResourceNameType

UnparsedResource

The contained UnparsedResourceName. Only non-nullif this instance contains an unparsed resource name.

Declaration
public UnparsedResourceName UnparsedResource { get; }
Property Value
Type Description
UnparsedResourceName

Methods

Equals(LocationName)

Declaration
public bool Equals(LocationName other)
Parameters
Type Name Description
LocationName other
Returns
Type Description
System.Boolean
Implements
System.IEquatable<T>.Equals(T)

Equals(Object)

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
System.Object obj
Returns
Type Description
System.Boolean
Overrides
System.Object.Equals(System.Object)

Format(String, String)

Formats the IDs into the string representation of this LocationName with pattern projects/{project}/locations/{location}.

Declaration
public static string Format(string projectId, string locationId)
Parameters
Type Name Description
System.String projectId

The Project ID. Must not be null or empty.

System.String locationId

The Location ID. Must not be null or empty.

Returns
Type Description
System.String

The string representation of this LocationName with pattern projects/{project}/locations/{location}.

FormatProjectLocation(String, String)

Formats the IDs into the string representation of this LocationName with pattern projects/{project}/locations/{location}.

Declaration
public static string FormatProjectLocation(string projectId, string locationId)
Parameters
Type Name Description
System.String projectId

The Project ID. Must not be null or empty.

System.String locationId

The Location ID. Must not be null or empty.

Returns
Type Description
System.String

The string representation of this LocationName with pattern projects/{project}/locations/{location}.

FromProjectLocation(String, String)

Creates a LocationName with the pattern projects/{project}/locations/{location}.

Declaration
public static LocationName FromProjectLocation(string projectId, string locationId)
Parameters
Type Name Description
System.String projectId

The Project ID. Must not be null or empty.

System.String locationId

The Location ID. Must not be null or empty.

Returns
Type Description
LocationName

A new instance of LocationName constructed from the provided ids.

FromUnparsed(UnparsedResourceName)

Creates a LocationName containing an unparsed resource name.

Declaration
public static LocationName FromUnparsed(UnparsedResourceName unparsedResourceName)
Parameters
Type Name Description
UnparsedResourceName unparsedResourceName

The unparsed resource name. Must not be null.

Returns
Type Description
LocationName

A new instance of LocationName containing the provided unparsedResourceName .

GetHashCode()

Declaration
public override int GetHashCode()
Returns
Type Description
System.Int32
Overrides
System.Object.GetHashCode()

Parse(String)

Parses the given resource name string into a new LocationName instance.

Declaration
public static LocationName Parse(string locationName)
Parameters
Type Name Description
System.String locationName

The resource name in string form. Must not be null.

Returns
Type Description
LocationName

The parsed LocationName if successful.

Remarks

To parse successfully, the resource name must be formatted as one of the following:

  • projects/{project}/locations/{location}

Parse(String, Boolean)

Parses the given resource name string into a new LocationName instance; optionally allowing an unparseable resource name.

Declaration
public static LocationName Parse(string locationName, bool allowUnparsed)
Parameters
Type Name Description
System.String locationName

The resource name in string form. Must not be null.

System.Boolean allowUnparsed

If true will successfully store an unparseable resource name into the UnparsedResource property; otherwise will throw an System.ArgumentException if an unparseable resource name is specified.

Returns
Type Description
LocationName

The parsed LocationName if successful.

Remarks

To parse successfully, the resource name must be formatted as one of the following:

  • projects/{project}/locations/{location}
Or may be in any format if allowUnparsed is true.

ToString()

The string representation of the resource name.

Declaration
public override string ToString()
Returns
Type Description
System.String

The string representation of the resource name.

Overrides
System.Object.ToString()
Implements
IResourceName.ToString()

TryParse(String, out LocationName)

Tries to parse the given resource name string into a new LocationName instance.

Declaration
public static bool TryParse(string locationName, out LocationName result)
Parameters
Type Name Description
System.String locationName

The resource name in string form. Must not be null.

LocationName result

When this method returns, the parsed LocationName, or null if parsing failed.

Returns
Type Description
System.Boolean

true if the name was parsed successfully; false otherwise.

Remarks

To parse successfully, the resource name must be formatted as one of the following:

  • projects/{project}/locations/{location}

TryParse(String, Boolean, out LocationName)

Tries to parse the given resource name string into a new LocationName instance; optionally allowing an unparseable resource name.

Declaration
public static bool TryParse(string locationName, bool allowUnparsed, out LocationName result)
Parameters
Type Name Description
System.String locationName

The resource name in string form. Must not be null.

System.Boolean allowUnparsed

If true will successfully store an unparseable resource name into the UnparsedResource property; otherwise will throw an System.ArgumentException if an unparseable resource name is specified.

LocationName result

When this method returns, the parsed LocationName, or null if parsing failed.

Returns
Type Description
System.Boolean

true if the name was parsed successfully; false otherwise.

Remarks

To parse successfully, the resource name must be formatted as one of the following:

  • projects/{project}/locations/{location}
Or may be in any format if allowUnparsed is true.

Operators

Equality(LocationName, LocationName)

Declaration
public static bool operator ==(LocationName a, LocationName b)
Parameters
Type Name Description
LocationName a
LocationName b
Returns
Type Description
System.Boolean

Inequality(LocationName, LocationName)

Declaration
public static bool operator !=(LocationName a, LocationName b)
Parameters
Type Name Description
LocationName a
LocationName b
Returns
Type Description
System.Boolean
Back to top