# Game Services v1 API - Class ServiceCollectionExtensions (2.2.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [2.2.0 (latest)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Gaming.V1/latest/Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions)
- [2.1.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Gaming.V1/2.1.0/Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions)
- [2.0.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Gaming.V1/2.0.0/Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions)
- [1.4.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Gaming.V1/1.4.0/Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions)
- [1.3.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Gaming.V1/1.3.0/Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions)
- [1.2.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Gaming.V1/1.2.0/Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions)
- [1.1.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Gaming.V1/1.1.0/Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions)

    public static class ServiceCollectionExtensions

Reference documentation and code samples for the Game Services v1 API class ServiceCollectionExtensions.

Static class to provide extension methods to configure API clients.

## Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) \> ServiceCollectionExtensions

## Inherited Members

[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) [object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone) [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Namespace

[Microsoft.Extensions.DependencyInjection](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Gaming.V1/latest/Microsoft.Extensions.DependencyInjection)

## Assembly

Google.Cloud.Gaming.V1.dll

## Methods

### AddGameServerClustersServiceClient(IServiceCollection, Action\<GameServerClustersServiceClientBuilder\>)

    public static IServiceCollection AddGameServerClustersServiceClient(this IServiceCollection services, Action<GameServerClustersServiceClientBuilder> action = null)

Adds a singleton [GameServerClustersServiceClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Gaming.V1/latest/Google.Cloud.Gaming.V1.GameServerClustersServiceClient) to `services`.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `services` | `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` The service collection to add the client to. The services are used to configure the client when requested. |
| `action` | `https://learn.microsoft.com/dotnet/api/system.action-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Gaming.V1/latest/Google.Cloud.Gaming.V1.GameServerClustersServiceClientBuilder` An optional action to invoke on the client builder. This is invoked before services from `services` are used. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` |   |

### AddGameServerConfigsServiceClient(IServiceCollection, Action\<GameServerConfigsServiceClientBuilder\>)

    public static IServiceCollection AddGameServerConfigsServiceClient(this IServiceCollection services, Action<GameServerConfigsServiceClientBuilder> action = null)

Adds a singleton [GameServerConfigsServiceClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Gaming.V1/latest/Google.Cloud.Gaming.V1.GameServerConfigsServiceClient) to `services`.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `services` | `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` The service collection to add the client to. The services are used to configure the client when requested. |
| `action` | `https://learn.microsoft.com/dotnet/api/system.action-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Gaming.V1/latest/Google.Cloud.Gaming.V1.GameServerConfigsServiceClientBuilder` An optional action to invoke on the client builder. This is invoked before services from `services` are used. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` |   |

### AddGameServerDeploymentsServiceClient(IServiceCollection, Action\<GameServerDeploymentsServiceClientBuilder\>)

    public static IServiceCollection AddGameServerDeploymentsServiceClient(this IServiceCollection services, Action<GameServerDeploymentsServiceClientBuilder> action = null)

Adds a singleton [GameServerDeploymentsServiceClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Gaming.V1/latest/Google.Cloud.Gaming.V1.GameServerDeploymentsServiceClient) to `services`.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `services` | `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` The service collection to add the client to. The services are used to configure the client when requested. |
| `action` | `https://learn.microsoft.com/dotnet/api/system.action-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Gaming.V1/latest/Google.Cloud.Gaming.V1.GameServerDeploymentsServiceClientBuilder` An optional action to invoke on the client builder. This is invoked before services from `services` are used. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` |   |

### AddRealmsServiceClient(IServiceCollection, Action\<RealmsServiceClientBuilder\>)

    public static IServiceCollection AddRealmsServiceClient(this IServiceCollection services, Action<RealmsServiceClientBuilder> action = null)

Adds a singleton [RealmsServiceClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Gaming.V1/latest/Google.Cloud.Gaming.V1.RealmsServiceClient) to `services`.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `services` | `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` The service collection to add the client to. The services are used to configure the client when requested. |
| `action` | `https://learn.microsoft.com/dotnet/api/system.action-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Gaming.V1/latest/Google.Cloud.Gaming.V1.RealmsServiceClientBuilder` An optional action to invoke on the client builder. This is invoked before services from `services` are used. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` |   |