20 lines
620 B
C#
20 lines
620 B
C#
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;
|
|
}
|
|
}
|