Show / Hide Table of Contents

Class ServiceEndpoint

Settings specifying a service endpoint in the form of a host name and port. This class is immutable and thread-safe.

Inheritance
System.Object
ServiceEndpoint
Implements
System.IEquatable<ServiceEndpoint>
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.Grpc
Assembly: Google.Api.Gax.Grpc.dll
Syntax
public sealed class ServiceEndpoint : IEquatable<ServiceEndpoint>

Constructors

ServiceEndpoint(String)

Creates a new endpoint with the given host, using a port of 443.

Declaration
public ServiceEndpoint(string host)
Parameters
Type Name Description
System.String host

The host name to connect to. Must not be null or empty.

ServiceEndpoint(String, Int32)

Creates a new endpoint with the given host and port.

Declaration
public ServiceEndpoint(string host, int port)
Parameters
Type Name Description
System.String host

The host name to connect to. Must not be null or empty.

System.Int32 port

The port to connect to, in the range 1 to 65535 inclusive.

Properties

Host

The host name to connect to. Never null or empty.

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

Port

The port to connect to, in the range 1 to 65535 inclusive.

Declaration
public int Port { get; }
Property Value
Type Description
System.Int32

Methods

Equals(ServiceEndpoint)

Determines equality between this endpoint and other.

Declaration
public bool Equals(ServiceEndpoint other)
Parameters
Type Name Description
ServiceEndpoint other

The object to compare with this one.

Returns
Type Description
System.Boolean

true if other is a ServiceEndpoint with the same host and port; false otherwise.

Implements
System.IEquatable<T>.Equals(T)

Equals(Object)

Determines equality between this object and obj.

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

The object to compare with this one.

Returns
Type Description
System.Boolean

true if obj is a ServiceEndpoint with the same host and port; false otherwise.

Overrides
System.Object.Equals(System.Object)

GetHashCode()

Returns a hash code for this object, consistent with Equals(ServiceEndpoint).

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

A hash code for this object.

Overrides
System.Object.GetHashCode()

Parse(String)

Parses the specified value as an endpoint.

Declaration
public static ServiceEndpoint Parse(string text)
Parameters
Type Name Description
System.String text

The text to parse.

Returns
Type Description
ServiceEndpoint

The resulting endpoint.

Remarks

Valid formats are:

The port defaults to 443 if it is not otherwise specified. If it is specified, it must be in the range 1-65535 inclusive.

Exceptions
Type Condition
System.ArgumentException

text does not represent a valid endpoint.

ToString()

Returns this endpoint's data in the format "host:port".

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

This endpoint's data in the format "host:port".

Overrides
System.Object.ToString()

TryParse(String, out ServiceEndpoint)

Tries to parse the specified value as an endpoint.

Declaration
public static bool TryParse(string text, out ServiceEndpoint endpoint)
Parameters
Type Name Description
System.String text

The text to parse.

ServiceEndpoint endpoint

The resulting endpoint, or null if the value could not be parsed.

Returns
Type Description
System.Boolean

true if the value was parsed successfully; false if parsing failed

Remarks

Valid formats are:

The port defaults to 443 if it is not otherwise specified. If it is specified, it must be in the range 1-65535 inclusive.

WithHost(String)

Creates a new endpoint with the same port but the given host.

Declaration
public ServiceEndpoint WithHost(string host)
Parameters
Type Name Description
System.String host

The host name to connect to. Must not be null or empty.

Returns
Type Description
ServiceEndpoint

A new endpoint with the current port and the specified host.

WithPort(Int32)

Creates a new endpoint with the same host but the given port.

Declaration
public ServiceEndpoint WithPort(int port)
Parameters
Type Name Description
System.Int32 port

The port to connect to, in the range 1 to 65535 inclusive.

Returns
Type Description
ServiceEndpoint

A new endpoint with the current host and the specified port.

Back to top