Added more ignorring namespaces (temporarelly)

This commit is contained in:
2026-03-06 15:00:35 +04:00
parent a948e5d15f
commit 4d45ec885e
+14 -10
View File
@@ -297,10 +297,18 @@ namespace Telegrator
/// </summary> /// </summary>
public static partial class HandlersCollectionExtensions 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"
]
/// <summary> /// <summary>
/// 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. /// Scans for types that implement handlers and adds them to the collection.
/// </summary> /// </summary>
/// <returns>This collection instance for method chaining.</returns> /// <returns>This collection instance for method chaining.</returns>
@@ -309,25 +317,21 @@ namespace Telegrator
{ {
AppDomain.CurrentDomain AppDomain.CurrentDomain
.GetAssemblies() .GetAssemblies()
.Where(ass => ass.GetName().Name != "Telegrator")
.Where(ass => skippingAssemblies.All(skip => !ass.FullName.StartsWith(skip))) .Where(ass => skippingAssemblies.All(skip => !ass.FullName.StartsWith(skip)))
.SelectMany(ass => ass.GetExportedTypes()) .ForEach(ass => ass.CollectHandlersAssemblyWide());
.Where(type => type.GetCustomAttribute<DontCollectAttribute>() == null)
.Where(type => type.IsHandlerRealization())
.ForEach(type => handlers.AddHandler(type));
return handlers; return handlers;
} }
/// <summary> /// <summary>
/// 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. /// Scans for types that implement handlers and adds them to the collection.
/// </summary> /// </summary>
/// <returns>This collection instance for method chaining.</returns> /// <returns>This collection instance for method chaining.</returns>
/// <exception cref="Exception">Thrown when the entry assembly cannot be found.</exception> /// <exception cref="Exception">Thrown when the entry assembly cannot be found.</exception>
public static IHandlersCollection CollectHandlersAssemblyWide(this IHandlersCollection handlers) public static IHandlersCollection CollectHandlersAssemblyWide(this IHandlersCollection handlers, Assembly collectingTarget = null)
{ {
Assembly.GetCallingAssembly() (collectingTarget ?? Assembly.GetCallingAssembly())
.GetExportedTypes() .GetExportedTypes()
.Where(type => type.GetCustomAttribute<DontCollectAttribute>() == null) .Where(type => type.GetCustomAttribute<DontCollectAttribute>() == null)
.Where(type => type.IsHandlerRealization()) .Where(type => type.IsHandlerRealization())