NewGaoKaoApi/New_College.Extensions/ServiceExtensions/AllOptionRegister.cs

20 lines
598 B
C#

using Microsoft.Extensions.DependencyInjection;
using New_College.Common;
using System;
using System.Linq;
namespace New_College.ServiceExtensions;
public static class AllOptionRegister
{
public static void AddAllOptionRegister(this IServiceCollection services)
{
if (services == null) throw new ArgumentNullException(nameof(services));
foreach (var optionType in App.EffectiveTypes.Where(s =>
!s.IsInterface && typeof(IConfigurableOptions).IsAssignableFrom(s)))
{
services.AddConfigurableOptions(optionType);
}
}
}