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