C# Класс Google.Api.Gax.PathTemplate

Represents a path template used for resource names which may be composed of multiple IDs.

Templates use a subset of the syntax of the API platform. See https://github.com/googleapis/googleapis/blob/master/google/api/http.proto for details of the API platform.

This class performs no URL escaping or unescaping. It is designed for use within GRPC, where no URL encoding is required.

Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
Expand ( ) : string

Validates that the given resource IDs are valid for this template, and returns a string representation

This is equivalent to calling new ResourceName(template, resourceIds).ToString(), but simpler in calling code and more efficient in terms of memory allocation.

This method assumes no service name is required. Call ExpandWithService to specify a service name.

ExpandWithService ( string serviceName ) : string

Validates that the given resource IDs are valid for this template, and returns a string representation

ParseName ( string name ) : ResourceName

Attempts to parse the given resource name against this template, throwing ArgumentException on failure.

PathTemplate ( string template ) : System

Constructs a template from its textual representation, such as shelves/*/books/**.

ToString ( ) : string

Returns the textual representation of this template.

TryParseName ( string name, ResourceName &result ) : bool

Attempts to parse the given resource name against this template, returning null on failure.

Although this method returns null if a name is passed in which doesn't match the template, it still throws ArgumentNullException if name is null, as this would usually indicate a programming error rather than a data error.

Приватные методы

Метод Описание
ReplaceParameters ( string serviceName, string resourceIds ) : string

Returns a string representation of the template with parameters replaced by resource IDs.

TryParseNameInternal ( string name, ResourceName &result ) : string

Implementation of parsing, returning the error message for a FormatException if parsing fails.

ValidateResourceId ( int index, string resourceId ) : void

Validate a single value from a sequence. This is used in both parsing and instantiating.

ValidateResourceIds ( string resourceIds ) : void

Validates a whole array of resource IDs, including that the count matches.

ValidateServiceName ( string serviceName, string parameterName ) : void

Validates a service name, ensuring it is not empty and doesn't contain any slashes. (In the future, we may want to make this stricter, e.g. that it's a valid DNS-like name.)

Описание методов

Expand() публичный Метод

Validates that the given resource IDs are valid for this template, and returns a string representation

This is equivalent to calling new ResourceName(template, resourceIds).ToString(), but simpler in calling code and more efficient in terms of memory allocation.

This method assumes no service name is required. Call ExpandWithService to specify a service name.

public Expand ( ) : string
Результат string

ExpandWithService() публичный Метод

Validates that the given resource IDs are valid for this template, and returns a string representation
public ExpandWithService ( string serviceName ) : string
serviceName string The service name, which may be null.
Результат string

ParseName() публичный Метод

Attempts to parse the given resource name against this template, throwing ArgumentException on failure.
public ParseName ( string name ) : ResourceName
name string The resource name to parse against this template. Must not be null.
Результат ResourceName

PathTemplate() публичный Метод

Constructs a template from its textual representation, such as shelves/*/books/**.
public PathTemplate ( string template ) : System
template string The textual representation of the template. Must not be null.
Результат System

ToString() публичный Метод

Returns the textual representation of this template.
public ToString ( ) : string
Результат string

TryParseName() публичный Метод

Attempts to parse the given resource name against this template, returning null on failure.
Although this method returns null if a name is passed in which doesn't match the template, it still throws ArgumentNullException if name is null, as this would usually indicate a programming error rather than a data error.
public TryParseName ( string name, ResourceName &result ) : bool
name string The resource name to parse against this template. Must not be null.
result ResourceName When this method returns, the parsed resource name or null if parsing fails.
Результат bool