# Class CallSettingsExtensions (4.10.0)

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

- [4.10.0 (latest)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettingsExtensions)
- [4.8.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/4.8.0/Google.Api.Gax.Grpc.CallSettingsExtensions)
- [4.4.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/4.4.0/Google.Api.Gax.Grpc.CallSettingsExtensions)
- [4.3.1](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/4.3.1/Google.Api.Gax.Grpc.CallSettingsExtensions)
- [4.2.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/4.2.0/Google.Api.Gax.Grpc.CallSettingsExtensions)
- [4.0.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/4.0.0/Google.Api.Gax.Grpc.CallSettingsExtensions)
- [3.2.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/3.2.0/Google.Api.Gax.Grpc.CallSettingsExtensions)

    public static class CallSettingsExtensions

Extension methods for [CallSettings](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings).
All methods accept a null first parameter as valid unless stated otherwise.

## Inheritance

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

## Inherited Members

[object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)) [object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)) [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.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals) [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Namespace

[Google.Api.Gax.Grpc](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc)

## Assembly

Google.Api.Gax.Grpc.dll

## Methods

### MergedWith(CallSettings, CallSettings)

    public static CallSettings MergedWith(this CallSettings original, CallSettings overlaid)

This method merges the settings in `overlaid` with those in
`original`, with `overlaid` taking priority.
If both arguments are null, the result is null. If one argument is null,
the other argument is returned. Otherwise, a new object is created with a property-wise
overlay, where null values do not override non-null values.
Any header mutations are combined, however: the mutation from the original is
performed, then the mutation in the overlay.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `original` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings` Original settings. May be null. |
| `overlaid` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings` Settings to overlay. May be null. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings` | A merged set of call settings, or null if both parameters are null. |

### WithCancellationToken(CallSettings, CancellationToken)

    public static CallSettings WithCancellationToken(this CallSettings settings, CancellationToken cancellationToken)

Returns a new [CallSettings](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings) with the specified cancellation token,
merged with the (optional) original settings specified by `settings`.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `settings` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings` Original settings. May be null, in which case the returned settings will only contain the cancellation token. |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` Cancellation token for the new call settings. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings` | A new set of call settings. |

### WithDeadline(CallSettings, DateTime)

    public static CallSettings WithDeadline(this CallSettings settings, DateTime deadline)

Returns a [CallSettings](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings) which will have the specified deadline.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `settings` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings` Existing settings. May be null, meaning there are currently no settings. |
| `deadline` | `https://learn.microsoft.com/dotnet/api/system.datetime` The deadline for the new settings. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings` | A new [CallSettings](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings) with the given deadline. |

### WithEarlierDeadline(CallSettings, DateTime?, IClock)

    public static CallSettings WithEarlierDeadline(this CallSettings settings, DateTime? deadline, IClock clock)

Returns a [CallSettings](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings) which will have an effective deadline of at least `deadline`.
If `settings` already observes an earlier deadline (with respect to `clock`),
or if `deadline` is null, the original settings will be returned.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `settings` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings` Existing settings. May be null, meaning there are currently no settings. |
| `deadline` | `https://learn.microsoft.com/dotnet/api/system.datetime` Deadline to enforce. May be null, meaning there is no deadline to enforce. |
| `clock` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.IClock` The clock to use when computing deadlines. Must not be null. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings` | The call settings to use to observe the given deadline. |

### WithExpiration(CallSettings, Expiration)

    public static CallSettings WithExpiration(this CallSettings settings, Expiration expiration)

Returns a new [CallSettings](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings) with the specified expiration,
merged with the (optional) original settings specified by `settings`.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `settings` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings` Original settings. May be null, in which case the returned settings will only contain the expiration. |
| `expiration` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Expiration` Expiration to use in the returned settings, possibly as part of a retry. May be null, in which case any expiration in `settings` is not present in the new call settings. If both this and `settings` are null, the return value is null. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings` | A new set of call settings with the specified expiration, or null of both parameters are null. |

### WithHeader(CallSettings, string, string)

    public static CallSettings WithHeader(this CallSettings settings, string name, string value)

Returns a new [CallSettings](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings) with the specified header,
merged with the (optional) original settings specified by `settings`.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `settings` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings` Original settings. May be null, in which case the returned settings will only contain the header. |
| `name` | `https://learn.microsoft.com/dotnet/api/system.string` Header name. Must not be null. |
| `value` | `https://learn.microsoft.com/dotnet/api/system.string` Header value. Must not be null. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings` | A new set of call settings including the specified header. |

**Remarks** Existing headers in settings will not be overritten, that is, if settings
already contains a header for `name` the new value
will be included in that header's set of values, even if it was already present
in settings for the header with the given name.

### WithResponseMetadataHandler(CallSettings, Action\<Metadata\>)

    public static CallSettings WithResponseMetadataHandler(this CallSettings settings, Action<Metadata> handler)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `settings` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings` |
| `handler` | `https://learn.microsoft.com/dotnet/api/system.action-1https://cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.Metadata.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings` |   |

### WithRetry(CallSettings, RetrySettings)

    public static CallSettings WithRetry(this CallSettings settings, RetrySettings retry)

Returns a new [CallSettings](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings) with the specified retry settings,
merged with the (optional) original settings specified by `settings`.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `settings` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings` Original settings. May be null, in which case the returned settings will only contain call timing. |
| `retry` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.RetrySettings` Call timing for the new call settings. This may be null, in which case any retry settings in `settings` are not present in the new call settings. If both this and `settings` are null, the return value is null. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings` | A new set of call settings, or null if both parameters are null. |

### WithTimeout(CallSettings, TimeSpan)

    public static CallSettings WithTimeout(this CallSettings settings, TimeSpan timeout)

Returns a [CallSettings](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings) which will have the specified timeout.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `settings` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings` Existing settings. May be null, meaning there are currently no settings. |
| `timeout` | `https://learn.microsoft.com/dotnet/api/system.timespan` The timeout for the new settings. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings` | A new [CallSettings](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings) with the given timeout. |

### WithTrailingMetadataHandler(CallSettings, Action\<Metadata\>)

    public static CallSettings WithTrailingMetadataHandler(this CallSettings settings, Action<Metadata> handler)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `settings` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings` |
| `handler` | `https://learn.microsoft.com/dotnet/api/system.action-1https://cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.Metadata.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings` |   |