Is your feature request related to a problem? Please describe.
Currently, the property BewitRegistrationBuilder.GetRepository is of type Func<INonceRepository>. This comes with certain limitations, as it is therefore not easily possible to consume services from the serviceProvider during the initialization of the NonceRepository.
Example from the MongoDB persistence package:
public static BewitRegistrationBuilder UseMongoPersistance(
this BewitRegistrationBuilder builder,
BewitMongoOptions options)
{
...
var client =
new MongoClient(options.ConnectionString);
IMongoDatabase db =
client.GetDatabase(options.DatabaseName);
builder.GetRepository = () => new NonceRepository(
db, options.CollectionName ?? nameof(Token));
return builder;
}
Describe the solution you'd like
BewitRegistrationBuilder.GetRepository should be of type Func<IServiceProvider, INonceRepository>. That way we could use registered services to initialize the NonceRepository:
builder.GetRepository = (ctx) => new NonceRepository(
ctx.GetRequiredService<IMongoDatabase>(), options.CollectionName ?? nameof(Token));