< Summary

Information
Class: Orchestrator.Infrastructure.ServiceRegistrationExtensions
Assembly: Orchestrator
File(s): /home/runner/work/KicktippAi/KicktippAi/src/Orchestrator/Infrastructure/ServiceRegistrationExtensions.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 49
Coverable lines: 49
Total lines: 245
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

File(s)

/home/runner/work/KicktippAi/KicktippAi/src/Orchestrator/Infrastructure/ServiceRegistrationExtensions.cs

#LineLine coverage
 1using Microsoft.Extensions.DependencyInjection;
 2using Microsoft.Extensions.DependencyInjection.Extensions;
 3using Microsoft.Extensions.Logging;
 4using Orchestrator.Infrastructure.Factories;
 5
 6namespace Orchestrator.Infrastructure;
 7
 8/// <summary>
 9/// Extension methods for registering Orchestrator services in dependency injection.
 10/// </summary>
 11public static class ServiceRegistrationExtensions
 12{
 13    /// <summary>
 14    /// Registers all shared infrastructure services (factories, logging).
 15    /// </summary>
 16    /// <remarks>
 17    /// This method is idempotent - calling it multiple times has no additional effect.
 18    /// </remarks>
 19    public static IServiceCollection AddOrchestratorInfrastructure(this IServiceCollection services)
 20    {
 21        // Add logging (idempotent via TryAdd internally)
 022        services.AddLogging(builder =>
 023        {
 024            builder.SetMinimumLevel(LogLevel.Information);
 025        });
 26
 27        // Add memory cache for Kicktipp client
 028        services.AddMemoryCache();
 29
 30        // Add HTTP client factory for Kicktipp
 031        services.AddHttpClient();
 32
 33        // Register factories (idempotent)
 034        services.TryAddSingleton<IFirebaseServiceFactory, FirebaseServiceFactory>();
 035        services.TryAddSingleton<IKicktippClientFactory, KicktippClientFactory>();
 036        services.TryAddSingleton<IOpenAiServiceFactory, OpenAiServiceFactory>();
 037        services.TryAddSingleton<IContextProviderFactory, ContextProviderFactory>();
 38
 039        return services;
 40    }
 41
 42    /// <summary>
 43    /// Registers services specific to the ListKpiCommand.
 44    /// </summary>
 45    /// <remarks>
 46    /// This method is idempotent and ensures infrastructure is registered.
 47    /// </remarks>
 48    public static IServiceCollection AddListKpiCommandServices(this IServiceCollection services)
 49    {
 050        services.AddOrchestratorInfrastructure();
 51
 52        // ListKpiCommand only needs Firebase factory (uses IKpiRepository)
 53        // No command-specific keyed services needed - factory pattern handles runtime config
 54
 055        return services;
 56    }
 57
 58    /// <summary>
 59    /// Registers services specific to the UploadKpiCommand.
 60    /// </summary>
 61    /// <remarks>
 62    /// This method is idempotent and ensures infrastructure is registered.
 63    /// </remarks>
 64    public static IServiceCollection AddUploadKpiCommandServices(this IServiceCollection services)
 65    {
 066        services.AddOrchestratorInfrastructure();
 67
 68        // UploadKpiCommand only needs Firebase factory (uses IKpiRepository)
 69        // No command-specific keyed services needed - factory pattern handles runtime config
 70
 071        return services;
 72    }
 73
 74    /// <summary>
 75    /// Registers services specific to the CostCommand.
 76    /// </summary>
 77    /// <remarks>
 78    /// This method is idempotent and ensures infrastructure is registered.
 79    /// </remarks>
 80    public static IServiceCollection AddCostCommandServices(this IServiceCollection services)
 81    {
 082        services.AddOrchestratorInfrastructure();
 83
 84        // CostCommand needs Firebase factory (uses IPredictionRepository, FirestoreDb)
 85        // No command-specific keyed services needed - factory pattern handles runtime config
 86
 087        return services;
 88    }
 89
 90    /// <summary>
 91    /// Registers services specific to the MatchdayCommand.
 92    /// </summary>
 93    /// <remarks>
 94    /// This method is idempotent and ensures infrastructure is registered.
 95    /// </remarks>
 96    public static IServiceCollection AddMatchdayCommandServices(this IServiceCollection services)
 97    {
 098        services.AddOrchestratorInfrastructure();
 99
 100        // MatchdayCommand needs all factories:
 101        // - Firebase (IPredictionRepository, IContextRepository)
 102        // - Kicktipp (IKicktippClient)
 103        // - OpenAI (IPredictionService, ITokenUsageTracker)
 104        // Factory pattern handles runtime config based on settings
 105
 0106        return services;
 107    }
 108
 109    /// <summary>
 110    /// Registers services specific to the BonusCommand.
 111    /// </summary>
 112    /// <remarks>
 113    /// This method is idempotent and ensures infrastructure is registered.
 114    /// </remarks>
 115    public static IServiceCollection AddBonusCommandServices(this IServiceCollection services)
 116    {
 0117        services.AddOrchestratorInfrastructure();
 118
 119        // BonusCommand needs all factories:
 120        // - Firebase (IPredictionRepository, IKpiRepository)
 121        // - Kicktipp (IKicktippClient)
 122        // - OpenAI (IPredictionService, ITokenUsageTracker)
 123
 0124        return services;
 125    }
 126
 127    /// <summary>
 128    /// Registers services specific to the VerifyMatchdayCommand.
 129    /// </summary>
 130    public static IServiceCollection AddVerifyMatchdayCommandServices(this IServiceCollection services)
 131    {
 0132        services.AddOrchestratorInfrastructure();
 133
 134        // VerifyMatchdayCommand needs:
 135        // - Firebase (IPredictionRepository, IContextRepository)
 136        // - Kicktipp (IKicktippClient)
 137
 0138        return services;
 139    }
 140
 141    /// <summary>
 142    /// Registers services specific to the VerifyBonusCommand.
 143    /// </summary>
 144    public static IServiceCollection AddVerifyBonusCommandServices(this IServiceCollection services)
 145    {
 0146        services.AddOrchestratorInfrastructure();
 147
 148        // VerifyBonusCommand needs:
 149        // - Firebase (IPredictionRepository, IKpiRepository)
 150        // - Kicktipp (IKicktippClient)
 151
 0152        return services;
 153    }
 154
 155    /// <summary>
 156    /// Registers services specific to the CollectContextKicktippCommand.
 157    /// </summary>
 158    public static IServiceCollection AddCollectContextKicktippCommandServices(this IServiceCollection services)
 159    {
 0160        services.AddOrchestratorInfrastructure();
 161
 162        // CollectContextKicktippCommand needs:
 163        // - Firebase (IContextRepository)
 164        // - Kicktipp (IKicktippClient)
 165
 0166        return services;
 167    }
 168
 169    /// <summary>
 170    /// Registers services specific to the ContextChangesCommand.
 171    /// </summary>
 172    public static IServiceCollection AddContextChangesCommandServices(this IServiceCollection services)
 173    {
 0174        services.AddOrchestratorInfrastructure();
 175
 176        // ContextChangesCommand only needs Firebase (IContextRepository)
 177
 0178        return services;
 179    }
 180
 181    /// <summary>
 182    /// Registers services specific to the UploadTransfersCommand.
 183    /// </summary>
 184    public static IServiceCollection AddUploadTransfersCommandServices(this IServiceCollection services)
 185    {
 0186        services.AddOrchestratorInfrastructure();
 187
 188        // UploadTransfersCommand only needs Firebase (IContextRepository)
 189
 0190        return services;
 191    }
 192
 193    /// <summary>
 194    /// Registers services specific to the AnalyzeMatchDetailedCommand.
 195    /// </summary>
 196    public static IServiceCollection AddAnalyzeMatchDetailedCommandServices(this IServiceCollection services)
 197    {
 0198        services.AddOrchestratorInfrastructure();
 199
 200        // AnalyzeMatchDetailedCommand needs:
 201        // - Firebase (IContextRepository)
 202        // - OpenAI (IPredictionService, ITokenUsageTracker)
 203
 0204        return services;
 205    }
 206
 207    /// <summary>
 208    /// Registers services specific to the AnalyzeMatchComparisonCommand.
 209    /// </summary>
 210    public static IServiceCollection AddAnalyzeMatchComparisonCommandServices(this IServiceCollection services)
 211    {
 0212        services.AddOrchestratorInfrastructure();
 213
 214        // AnalyzeMatchComparisonCommand needs:
 215        // - Firebase (IContextRepository)
 216        // - OpenAI (IPredictionService, ITokenUsageTracker)
 217
 0218        return services;
 219    }
 220
 221    /// <summary>
 222    /// Registers all command services. Useful for production setup.
 223    /// </summary>
 224    public static IServiceCollection AddAllCommandServices(this IServiceCollection services)
 225    {
 226        // Infrastructure is added by each command method, but we call it first for clarity
 0227        services.AddOrchestratorInfrastructure();
 228
 229        // Register all command-specific services
 0230        services.AddListKpiCommandServices();
 0231        services.AddUploadKpiCommandServices();
 0232        services.AddCostCommandServices();
 0233        services.AddMatchdayCommandServices();
 0234        services.AddBonusCommandServices();
 0235        services.AddVerifyMatchdayCommandServices();
 0236        services.AddVerifyBonusCommandServices();
 0237        services.AddCollectContextKicktippCommandServices();
 0238        services.AddContextChangesCommandServices();
 0239        services.AddUploadTransfersCommandServices();
 0240        services.AddAnalyzeMatchDetailedCommandServices();
 0241        services.AddAnalyzeMatchComparisonCommandServices();
 242
 0243        return services;
 244    }
 245}