Amazon.Lambda.Annotations: allow an alternate IServiceProvider implementation
- Lingua principale
- C#
- Stelle
- 1.7k
- Fork
- 503
- Merge medio
- 1g 13h
- PR unite (30g)
- 19
Descrizione
### Describe the feature
Provide a way of using an inversion of control container other than the default Microsoft.Extensions.DependencyInjection.
### Use Case
I would like to be able to use Autofac with Amazon.Lambda.Annotations.
### Proposed Solution
A formal api around a Startup class would work, but it looks like a small tweak to the generated code may be sufficient to hook in an alternate IServiceProvider.
The serviceProvider is currently stored in a field defined like this:
`private readonly ServiceProvider serviceProvider;`
The field is using the concrete type _ServiceProvider_. If the field type were changed to _IServiceProvider_ that would allow a different _IServiceProvider_ to be used by implementing a _BuildServiceProvider_ extension method in the Lambda project.
```
public static AutofacServiceProvider BuildServiceProvider(this IServiceCollection services)
{
var builder = new ContainerBuilder();
builder.Populate(services);
return new AutofacServiceProvider(builder.Build());
}
```
### Other Information
_No response_
### Acknowledgements
- [ ] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
### AWS .NET SDK and/or Package version used
Amazon.Lambda.Annotations 1.3.0
### Targeted .NET Platform
.Net 8
### Operating System and version
AmazonLinux
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia tracciando il codice generato da Amazon.Lambda.Annotations che dichiara il campo concreto serviceProvider e il punto di estensione BuildServiceProvider descritto nell’issue. Determina se la modifica del campo in IServiceProvider supporta container alternativi senza un’API Startup più ampia, quindi verifica il comportamento del codice generato per l’integrazione Autofac richiesta.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- aws, csharp
- Ambito
- backend, cloud
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 38/100