using BililiveRecorder.Core; using BililiveRecorder.Core.Api; using BililiveRecorder.Core.Api.Danmaku; using BililiveRecorder.Core.Api.Http; using BililiveRecorder.Core.Config.V2; using BililiveRecorder.Core.Danmaku; using BililiveRecorder.Core.Recording; using BililiveRecorder.Flv; using Microsoft.Extensions.DependencyInjection; using Polly.Registry; namespace BililiveRecorder.DependencyInjection { public static class DependencyInjectionExtensions { public static IServiceCollection AddRecorderConfig(this IServiceCollection services, ConfigV2 config) => services .AddSingleton(config) .AddSingleton(sp => sp.GetRequiredService().Global) ; public static IServiceCollection AddRecorder(this IServiceCollection services) => services .AddSingleton() .AddRecorderPollyPolicy() .AddRecorderApiClients() .AddRecorderRecording() .AddSingleton() .AddSingleton() .AddScoped() ; private static IServiceCollection AddRecorderPollyPolicy(this IServiceCollection services) => services .AddSingleton() .AddSingleton>(sp => sp.GetRequiredService()) ; public static IServiceCollection AddRecorderApiClients(this IServiceCollection services) => services .AddSingleton() .AddSingleton>() .AddSingleton(sp => sp.GetRequiredService>()) .AddSingleton(sp => sp.GetRequiredService>()) .AddScoped() ; public static IServiceCollection AddRecorderRecording(this IServiceCollection services) => services .AddScoped() .AddScoped() .AddScoped() .AddScoped() ; } }