From 4d45ec885e19b096197af858fc88091e2371ac82 Mon Sep 17 00:00:00 2001 From: Rikitav Date: Fri, 6 Mar 2026 15:00:35 +0400 Subject: [PATCH] Added more ignorring namespaces (temporarelly) --- Telegrator/TypesExtensions.cs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/Telegrator/TypesExtensions.cs b/Telegrator/TypesExtensions.cs index 8ee6452..d32c93f 100644 --- a/Telegrator/TypesExtensions.cs +++ b/Telegrator/TypesExtensions.cs @@ -297,10 +297,18 @@ namespace Telegrator /// public static partial class HandlersCollectionExtensions { - private static readonly string[] skippingAssemblies = ["System.", "Microsoft."]; + // TODO: rewrite collecting system, add certain hardcoded Type searching, generated automatically + private static readonly string[] skippingAssemblies = [ + "System", "Microsoft", "Windows", "Newtonsoft", "Serilog", "NLog", + "AutoMapper", "MediatR", "Dapper", "RestSharp", "Polly", "FluentValidation", + "NUnit", "Xunit", "Moq", "FluentAssertions", "Castle", "Autofac", "Ninject", + "StackExchange", "RabbitMQ", "Quartz", "Hangfire", "Npgsql", "MySql", "Oracle", + "Bogus", "CsvHelper", "Grpc", "Swashbuckle", "MassTransit", "AngleSharp", + "Ocelot", "BouncyCastle", "IdentityModel", "Telegrator" + ] /// - /// Collects all handlers from the current app domain. + /// Collects all public handlers from the current app domain. /// Scans for types that implement handlers and adds them to the collection. /// /// This collection instance for method chaining. @@ -309,25 +317,21 @@ namespace Telegrator { AppDomain.CurrentDomain .GetAssemblies() - .Where(ass => ass.GetName().Name != "Telegrator") .Where(ass => skippingAssemblies.All(skip => !ass.FullName.StartsWith(skip))) - .SelectMany(ass => ass.GetExportedTypes()) - .Where(type => type.GetCustomAttribute() == null) - .Where(type => type.IsHandlerRealization()) - .ForEach(type => handlers.AddHandler(type)); + .ForEach(ass => ass.CollectHandlersAssemblyWide()); return handlers; } /// - /// Collects all handlers from the calling this function assembly. + /// Collects all public handlers from the calling this function assembly. /// Scans for types that implement handlers and adds them to the collection. /// /// This collection instance for method chaining. /// Thrown when the entry assembly cannot be found. - public static IHandlersCollection CollectHandlersAssemblyWide(this IHandlersCollection handlers) + public static IHandlersCollection CollectHandlersAssemblyWide(this IHandlersCollection handlers, Assembly collectingTarget = null) { - Assembly.GetCallingAssembly() + (collectingTarget ?? Assembly.GetCallingAssembly()) .GetExportedTypes() .Where(type => type.GetCustomAttribute() == null) .Where(type => type.IsHandlerRealization())