Files
WebNovelPortal/WebNovelPortalAPI/Extensions/ScraperExtensions.cs
littlefoot e6d6b629db
Some checks failed
continuous-integration/drone/push Build is failing
db changes and build pipeline
2022-07-15 12:21:37 -04:00

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);
}
}
}