> ## Documentation Index
> Fetch the complete documentation index at: https://easyaf.nimbleapps.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# RestierContainerBuilder

> The default Dependency Injection container builder for Restier.

## Definition

**Assembly:** Microsoft.Restier.Core.dll

**Namespace:** Microsoft.Restier.Core

**Inheritance:** System.Object

## Syntax

```csharp theme={"dark"}
Microsoft.Restier.Core.RestierContainerBuilder
```

## Summary

The default Dependency Injection container builder for Restier.

## Constructors

### &#x20;.ctor

Initializes a new instance of the [RestierContainerBuilder](https://easyaf.nimbleapps.cloud/restier/api-reference/Microsoft/Restier/Core/RestierContainerBuilder.md) class.

#### Syntax

```csharp theme={"dark"}
public RestierContainerBuilder(System.Action<Microsoft.Restier.Core.RestierApiBuilder> configureApis = null)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `configureApis` | `System.Action<Microsoft.Restier.Core.RestierApiBuilder>` | Action to configure the [ApiBase](https://easyaf.nimbleapps.cloud/restier/api-reference/Microsoft/Restier/Core/ApiBase.md) registrations that are available to the Container. |

#### Remarks

The API registrations are re-created every time because new Containers are spun up per-route. It make make more sense to create a static
instance to do this, so the Dictionary is only created once.

### &#x20;.ctor Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public Object()
```

## Methods

### &#x20;AddService

Adds a service of *serviceType* with an *implementationType*.

#### Syntax

```csharp theme={"dark"}
public Microsoft.OData.IContainerBuilder AddService(Microsoft.OData.ServiceLifetime lifetime, System.Type serviceType, System.Type implementationType)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `lifetime` | `Microsoft.OData.ServiceLifetime` | The lifetime of the service to register. |
| `serviceType` | `System.Type` | The type of the service to register. |
| `implementationType` | `System.Type` | The implementation type of the service. |

#### Returns

Type: `Microsoft.OData.IContainerBuilder`
The [IContainerBuilder](https://learn.microsoft.com/dotnet/api/microsoft.odata.icontainerbuilder) instance itself.

### &#x20;AddService

Adds a service of *serviceType* with an *implementationFactory*.

#### Syntax

```csharp theme={"dark"}
public Microsoft.OData.IContainerBuilder AddService(Microsoft.OData.ServiceLifetime lifetime, System.Type serviceType, System.Func<System.IServiceProvider, object> implementationFactory)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `lifetime` | `Microsoft.OData.ServiceLifetime` | The lifetime of the service to register. |
| `serviceType` | `System.Type` | The type of the service to register. |
| `implementationFactory` | `System.Func<System.IServiceProvider, object>` | The factory that creates the service. |

#### Returns

Type: `Microsoft.OData.IContainerBuilder`
The [IContainerBuilder](https://learn.microsoft.com/dotnet/api/microsoft.odata.icontainerbuilder) instance itself.

### &#x20;BuildContainer Virtual

Builds a container which implements [IServiceProvider](https://learn.microsoft.com/dotnet/api/system.iserviceprovider) and contains all the services registered for a specific route.

#### Syntax

```csharp theme={"dark"}
public virtual System.IServiceProvider BuildContainer()
```

#### Returns

Type: `System.IServiceProvider`
The [IServiceProvider](https://learn.microsoft.com/dotnet/api/system.iserviceprovider)dependency injection container\</see> for the registered services.

#### Remarks

RWM: For unit test scenarios, this container may be built without any APIs opr Routes. If you are experiencing unexpected behavior,
turn on Tracing so you can see the warning messages Restier might be generating.

### &#x20;Equals Inherited Virtual

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public virtual bool Equals(object obj)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `obj` | `object?` | - |

#### Returns

Type: `bool`

### &#x20;Equals Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public static bool Equals(object objA, object objB)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `objA` | `object?` | - |
| `objB` | `object?` | - |

#### Returns

Type: `bool`

### &#x20;GetHashCode Inherited Virtual

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public virtual int GetHashCode()
```

#### Returns

Type: `int`

### &#x20;GetType Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public System.Type GetType()
```

#### Returns

Type: `System.Type`

### &#x20;MemberwiseClone Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
protected internal object MemberwiseClone()
```

#### Returns

Type: `object`

### &#x20;ReferenceEquals Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public static bool ReferenceEquals(object objA, object objB)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `objA` | `object?` | - |
| `objB` | `object?` | - |

#### Returns

Type: `bool`

### &#x20;ToString Inherited Virtual

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public virtual string ToString()
```

#### Returns

Type: `string?`

## Related APIs

* Microsoft.OData.IContainerBuilder


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.