From 088d6166ce73b8704904dbb81d5e9325b5687405 Mon Sep 17 00:00:00 2001 From: Rikitav Date: Fri, 1 Aug 2025 15:48:54 +0400 Subject: [PATCH] * Method descriptor creation hotfix --- .../Descriptors/DefaultCustomDescriptors.cs | 2 +- .../Descriptors/HandlerDescriptor.cs | 19 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Telegrator/MadiatorCore/Descriptors/DefaultCustomDescriptors.cs b/Telegrator/MadiatorCore/Descriptors/DefaultCustomDescriptors.cs index c9a8a5f..caa272b 100644 --- a/Telegrator/MadiatorCore/Descriptors/DefaultCustomDescriptors.cs +++ b/Telegrator/MadiatorCore/Descriptors/DefaultCustomDescriptors.cs @@ -19,7 +19,7 @@ namespace Telegrator.MadiatorCore.Descriptors /// Initializes new instance of /// /// - public MethodHandlerDescriptor(AbstractHandlerAction action) : base(DescriptorType.General) + public MethodHandlerDescriptor(AbstractHandlerAction action) : base(DescriptorType.General, typeof(MethodHandler), true) { UpdateHandlerAttributeBase handlerAttribute = HandlerInspector.GetHandlerAttribute(action.Method); StateKeeperAttributeBase? stateKeeperAttribute = HandlerInspector.GetStateKeeperAttribute(action.Method); diff --git a/Telegrator/MadiatorCore/Descriptors/HandlerDescriptor.cs b/Telegrator/MadiatorCore/Descriptors/HandlerDescriptor.cs index fe5c164..8f9de2b 100644 --- a/Telegrator/MadiatorCore/Descriptors/HandlerDescriptor.cs +++ b/Telegrator/MadiatorCore/Descriptors/HandlerDescriptor.cs @@ -127,22 +127,23 @@ namespace Telegrator.MadiatorCore.Descriptors set; } - internal HandlerDescriptor(DescriptorType descriptorType) - { - Type = descriptorType; - HandlerType = null!; - Filters = new DescriptorFiltersSet(null, null, null); - } - /// /// Initializes a new instance of the class with the specified descriptor type and handler type. /// Automatically inspects the handler type to extract attributes, filters, and configuration. /// /// The type of the descriptor /// The type of the handler to describe + /// /// Thrown when the handler type is not compatible with the expected handler type - public HandlerDescriptor(DescriptorType descriptorType, Type handlerType) + public HandlerDescriptor(DescriptorType descriptorType, Type handlerType, bool dontInspect = false) { + Type = descriptorType; + HandlerType = handlerType; + Filters = new DescriptorFiltersSet(null, null, null); + + if (dontInspect) + return; + UpdateHandlerAttributeBase handlerAttribute = HandlerInspector.GetHandlerAttribute(handlerType); if (handlerAttribute.ExpectingHandlerType != null && !handlerAttribute.ExpectingHandlerType.Contains(handlerType.BaseType)) throw new ArgumentException(string.Format("This handler attribute cannot be attached to this class. Attribute can be attached on next handlers : {0}", string.Join(", ", handlerAttribute.ExpectingHandlerType.AsEnumerable()))); @@ -150,8 +151,6 @@ namespace Telegrator.MadiatorCore.Descriptors StateKeeperAttributeBase? stateKeeperAttribute = HandlerInspector.GetStateKeeperAttribute(handlerType); IFilter[] filters = HandlerInspector.GetFilterAttributes(handlerType, handlerAttribute.Type).ToArray(); - Type = descriptorType; - HandlerType = handlerType; UpdateType = handlerAttribute.Type; Indexer = handlerAttribute.GetIndexer(); Filters = new DescriptorFiltersSet(handlerAttribute, stateKeeperAttribute, filters);