using System.Reflection; using WebNovelPortalAPI.Scrapers; namespace WebNovelPortalAPI.Extensions; public static class ScraperExtensions { public static void AddScrapers(this IServiceCollection services) { Type[] types = Assembly.GetExecutingAssembly().GetTypes().Where(t => t.IsClass && typeof(IScraper).IsAssignableFrom(t) && (t.Namespace?.Contains(nameof(Scrapers)) ?? false)) .ToArray(); foreach (var t in types) { services.AddScoped(typeof(IScraper), t); } } }