~ruther/NosSmooth

5e14c4fb272f3b170e7c0855921bfb9fc63eea1a — František Boháček 3 years ago 99748bb
feat: implement adding generated serializers
1 files changed, 11 insertions(+), 1 deletions(-)

M Core/NosSmooth.Packets/Extensions/ServiceCollectionExtensions.cs
M Core/NosSmooth.Packets/Extensions/ServiceCollectionExtensions.cs => Core/NosSmooth.Packets/Extensions/ServiceCollectionExtensions.cs +11 -1
@@ 46,7 46,17 @@ public static class ServiceCollectionExtensions
    /// <returns>The collection.</returns>
    public static IServiceCollection AddGeneratedSerializers(this IServiceCollection serviceCollection, Assembly assembly)
    {
        throw new NotImplementedException();
        var types = assembly.GetExportedTypes()
            .Where(x => x.Namespace?.Contains("Generated") ?? false)
            .Where(x => x.GetInterfaces().Any(
                i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(ITypeConverter<>)
            ));
        foreach (var type in types)
        {
            serviceCollection.AddTypeConverter(type);
        }

        return serviceCollection;
    }

    /// <summary>

Do not follow this link