# DirectorySiloBuilderExtensions.AddGrainDirectory(IServiceCollection, string, Func&lt;IServiceProvider, string, T&gt;)

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.runtime/orleans.runtime.hosting.directorysilobuilderextensions/) | [Methods](/orleans/docs/api/csharp/microsoft.orleans.runtime/orleans.runtime.hosting.directorysilobuilderextensions/methods/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Runtime/Hosting/DirectorySiloBuilderExtensions.cs#L40-L47)

```csharp
public static IServiceCollection AddGrainDirectory<T>(this IServiceCollection collection, string name, Func<IServiceProvider, string, T> implementationFactory)
```

Add a grain directory provider implementation to the silo. If the provider type implements `Orleans.ILifecycleParticipant-1` it will automatically participate to the silo lifecycle.

### Parameters

- `collection` (`IServiceCollection`): The service collection.
- `name` (`string`): The name of the grain directory to add.
- `implementationFactory` (`Func<IServiceProvider, string, T>`): Factory to build the grain directory provider.

### Returns

The service collection.
