> ## Documentation Index
> Fetch the complete documentation index at: https://easyaf.dev/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

### <Icon icon="hammer" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> .ctor

Initializes a new instance of the [RestierContainerBuilder](/restier/api-reference/Microsoft/Restier/Core/RestierContainerBuilder) 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](/restier/api-reference/Microsoft/Restier/Core/ApiBase) 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.

### <Icon icon="hammer" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> .ctor <Badge color="gray">Inherited</Badge>

<Note>Inherited from `object`</Note>

#### Syntax

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

## Methods

### <Icon icon="function" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> 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.

### <Icon icon="function" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> 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.

### <Icon icon="code-fork" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> BuildContainer <Badge color="orange">Virtual</Badge>

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.

### <Icon icon="code-fork" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> Equals <Badge color="gray">Inherited</Badge> <Badge color="orange">Virtual</Badge>

<Note>Inherited from `object`</Note>

#### Syntax

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

#### Parameters

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

#### Returns

Type: `bool`

### <Icon icon="thumbtack" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> Equals <Badge color="gray">Inherited</Badge>

<Note>Inherited from `object`</Note>

#### Syntax

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

#### Parameters

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

#### Returns

Type: `bool`

### <Icon icon="code-fork" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> GetHashCode <Badge color="gray">Inherited</Badge> <Badge color="orange">Virtual</Badge>

<Note>Inherited from `object`</Note>

#### Syntax

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

#### Returns

Type: `int`

### <Icon icon="function" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> GetType <Badge color="gray">Inherited</Badge>

<Note>Inherited from `object`</Note>

#### Syntax

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

#### Returns

Type: `System.Type`

### <Icon icon="function" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> MemberwiseClone <Badge color="gray">Inherited</Badge>

<Note>Inherited from `object`</Note>

#### Syntax

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

#### Returns

Type: `object`

### <Icon icon="thumbtack" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> ReferenceEquals <Badge color="gray">Inherited</Badge>

<Note>Inherited from `object`</Note>

#### Syntax

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

#### Parameters

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

#### Returns

Type: `bool`

### <Icon icon="code-fork" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> ToString <Badge color="gray">Inherited</Badge> <Badge color="orange">Virtual</Badge>

<Note>Inherited from `object`</Note>

#### Syntax

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

#### Returns

Type: `string?`

## Related APIs

* Microsoft.OData.IContainerBuilder
