18 lines
568 B
C#
18 lines
568 B
C#
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.IsAbstract && (t.Namespace?.Contains(nameof(Scrapers)) ?? false))
|
|
.ToArray();
|
|
foreach (var t in types)
|
|
{
|
|
services.AddScoped(typeof(IScraper), t);
|
|
}
|
|
}
|
|
} |