| | | 1 | | using ContextProviders.Kicktipp; |
| | | 2 | | using EHonda.KicktippAi.Core; |
| | | 3 | | using FirebaseAdapter; |
| | | 4 | | using KicktippIntegration; |
| | | 5 | | using Microsoft.Extensions.FileProviders; |
| | | 6 | | using Microsoft.Extensions.Logging; |
| | | 7 | | |
| | | 8 | | namespace Orchestrator.Infrastructure.Factories; |
| | | 9 | | |
| | | 10 | | /// <summary> |
| | | 11 | | /// Default implementation of <see cref="IContextProviderFactory"/>. |
| | | 12 | | /// </summary> |
| | | 13 | | public sealed class ContextProviderFactory : IContextProviderFactory |
| | | 14 | | { |
| | | 15 | | private readonly Lazy<IFileProvider> _communityRulesFileProvider; |
| | | 16 | | private readonly IFirebaseServiceFactory _firebaseServiceFactory; |
| | | 17 | | private readonly ILogger<FirebaseKpiContextProvider> _kpiContextProviderLogger; |
| | | 18 | | |
| | 0 | 19 | | public ContextProviderFactory( |
| | 0 | 20 | | IFirebaseServiceFactory firebaseServiceFactory, |
| | 0 | 21 | | ILogger<FirebaseKpiContextProvider> kpiContextProviderLogger) |
| | | 22 | | { |
| | 0 | 23 | | _communityRulesFileProvider = new Lazy<IFileProvider>( |
| | 0 | 24 | | ContextProviders.Kicktipp.CommunityRulesFileProvider.Create); |
| | 0 | 25 | | _firebaseServiceFactory = firebaseServiceFactory; |
| | 0 | 26 | | _kpiContextProviderLogger = kpiContextProviderLogger; |
| | 0 | 27 | | } |
| | | 28 | | |
| | | 29 | | /// <inheritdoc /> |
| | 0 | 30 | | public IFileProvider CommunityRulesFileProvider => _communityRulesFileProvider.Value; |
| | | 31 | | |
| | | 32 | | /// <inheritdoc /> |
| | | 33 | | public IKicktippContextProvider CreateKicktippContextProvider( |
| | | 34 | | IKicktippClient kicktippClient, |
| | | 35 | | string community, |
| | | 36 | | string? communityContext = null) |
| | | 37 | | { |
| | 0 | 38 | | return new KicktippContextProvider( |
| | 0 | 39 | | kicktippClient, |
| | 0 | 40 | | CommunityRulesFileProvider, |
| | 0 | 41 | | community, |
| | 0 | 42 | | communityContext); |
| | | 43 | | } |
| | | 44 | | |
| | | 45 | | /// <inheritdoc /> |
| | | 46 | | public IKpiContextProvider CreateKpiContextProvider() |
| | | 47 | | { |
| | 0 | 48 | | var kpiRepository = _firebaseServiceFactory.CreateKpiRepository(); |
| | 0 | 49 | | return new FirebaseKpiContextProvider(kpiRepository, _kpiContextProviderLogger); |
| | | 50 | | } |
| | | 51 | | } |