From c378ddba07366b24fde3325d6860576763ae19c4 Mon Sep 17 00:00:00 2001 From: Timothy Schenk Date: Sun, 4 Feb 2024 20:13:36 +0100 Subject: [PATCH] chore: cleanup of Masstransit library --- Rai.PacketMediator/PacketDistributorService.cs | 9 ++++----- Rai.PacketMediator/Rai.PacketMediator.csproj | 1 - 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Rai.PacketMediator/PacketDistributorService.cs b/Rai.PacketMediator/PacketDistributorService.cs index 5ff6005..e0cb920 100644 --- a/Rai.PacketMediator/PacketDistributorService.cs +++ b/Rai.PacketMediator/PacketDistributorService.cs @@ -7,7 +7,6 @@ using System.Reflection; using DotNext.Collections.Generic; using DotNext.Linq.Expressions; using DotNext.Metaprogramming; -using MassTransit.Internals; using Microsoft.Extensions.DependencyInjection; using Microsoft.VisualBasic.CompilerServices; @@ -41,8 +40,8 @@ public class PacketDistributorService : Microsoft.Extensions.Hosting.IHost { using var activity = this._activitySource.StartActivity(); var packetsWithId = this._sourcesContainingPackets.SelectMany(a => a.GetTypes() - .Where(type => - type.HasInterface(typeof(IIncomingPacket)) && type is { IsInterface: false, IsAbstract: false }) + .Where(type => type is { IsInterface: false, IsAbstract: false } && + type.GetInterfaces().Contains(typeof(IIncomingPacket))) .Select(type => new { Type = type, Attribute = type.GetCustomAttribute>() }) .Where(item => item.Attribute is not null) .ToDictionary(item => item.Attribute!.Code, item => item.Type)).ToDictionary(); @@ -66,8 +65,8 @@ public class PacketDistributorService : Microsoft.Extensions.Hosting.IHost PacketId = type .GetInterfaces().First(t1 => t1 is { IsGenericType: true } && t1.GetGenericTypeDefinition() == typeof(IPacketHandler)) - .GetGenericArguments().First(t => t.HasAttribute>()) - .GetAttribute>().First().Code + .GetGenericArguments().First(t => t.GetCustomAttributes>().Any()) + .GetCustomAttributes>().First().Code }) .ToDictionary( x => x.PacketId, x => x.Type diff --git a/Rai.PacketMediator/Rai.PacketMediator.csproj b/Rai.PacketMediator/Rai.PacketMediator.csproj index b6b02dd..94a160a 100644 --- a/Rai.PacketMediator/Rai.PacketMediator.csproj +++ b/Rai.PacketMediator/Rai.PacketMediator.csproj @@ -12,7 +12,6 @@ -