Snowflake/RPG.Services.Gameserver/Extensions/ServiceCollectionExtensions.cs
2024-01-19 17:45:18 +03:00

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