feat: Implement ServiceFactory for dependency injection

- Added ServiceFactory class to manage service registrations and service provider creation.
- Implemented a lazy-loaded IServiceProvider to ensure services are only built once.
- Prevent further modifications to the service collection after the service provider is created.
- Added Provide<T>() method to resolve and retrieve services from the service provider.
This commit is contained in:
Developer 02
2024-06-27 12:29:31 +02:00
parent c09ff44287
commit f128a719e8
5 changed files with 47 additions and 108 deletions

View File

@@ -18,6 +18,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="7.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>