KafkaSR/RPG.Services.Gameserver/Extensions/ServiceCollectionExtensions.cs

21 lines
620 B
C#
Raw Normal View History

2024-01-29 23:49:21 +00:00
using System.Reflection;
using Microsoft.Extensions.DependencyInjection;
using RPG.Services.Gameserver.Modules;
namespace RPG.Services.Gameserver.Extensions;
internal static class ServiceCollectionExtensions
{
public static IServiceCollection AddModules(this IServiceCollection services)
{
IEnumerable<Type> types = Assembly.GetExecutingAssembly().GetTypes()
.Where(type => type.IsAssignableTo(typeof(BaseModule)) && !type.IsAbstract);
foreach (Type type in types)
{
services.AddScoped(type);
}
return services;
}
}