mirror of
https://github.com/thebreaddev/Supercell.GUT.git
synced 2024-11-14 01:14:37 +00:00
21 lines
626 B
C#
21 lines
626 B
C#
|
using System.Reflection;
|
|||
|
using Microsoft.Extensions.DependencyInjection;
|
|||
|
using Supercell.GUT.Server.Protocol.Attributes;
|
|||
|
|
|||
|
namespace Supercell.GUT.Server.Protocol.Extensions;
|
|||
|
internal static class ServiceCollectionExtensions
|
|||
|
{
|
|||
|
public static IServiceCollection AddHandlers(this IServiceCollection services)
|
|||
|
{
|
|||
|
IEnumerable<Type> types = Assembly.GetExecutingAssembly().GetTypes()
|
|||
|
.Where(t => t.GetCustomAttribute<ServiceNodeAttribute>() != null);
|
|||
|
|
|||
|
foreach (Type type in types)
|
|||
|
{
|
|||
|
services.AddScoped(type);
|
|||
|
}
|
|||
|
|
|||
|
return services;
|
|||
|
}
|
|||
|
}
|