Mile
Managing Scoped Service Lifecycles with a Singleton Factory in .NET: Best Practices?
Hello everyone,
I'm working on implementing a factory pattern for payment services in a .NET application and I'm unsure about properly managing the lifecycle of services. Here's the relevant part of my code:
And here's how I'm using it in a handler:
The ProviderServiceFactory is registered as a Singleton, while the payment services (like PayPalService) are registered as Scoped.
66 replies