AdventOfCode/AdventOfCode.Solutions/ServiceConfiguration.cs
2024-12-02 08:46:18 +01:00

22 lines
658 B
C#

using AdventOfCode.Solutions._2024;
using Microsoft.Extensions.DependencyInjection;
namespace AdventOfCode.Solutions
{
public static class ServiceConfiguration
{
public static IServiceCollection AddChallanges(this IServiceCollection services)
{
IEnumerable<Type> challanges = AppDomain.CurrentDomain.GetAssemblies().SelectMany(a => a.GetTypes())
.Where(t => t.GetInterfaces().Contains(typeof(IChallange)));
foreach (Type challange in challanges)
{
services.AddScoped(typeof(IChallange), challange);
}
return services;
}
}
}