diff --git a/.gitignore b/.gitignore
index 9491a2f..a8546f7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -360,4 +360,5 @@ MigrationBackup/
.ionide/
# Fody - auto-generated XML schema
-FodyWeavers.xsd
\ No newline at end of file
+FodyWeavers.xsd
+/GETTING_STARTED.md
diff --git a/Telegrator/Aspects/AfterExecutionAttribute.cs b/Telegrator/Aspects/AfterExecutionAttribute.cs
index 21be3da..7835048 100644
--- a/Telegrator/Aspects/AfterExecutionAttribute.cs
+++ b/Telegrator/Aspects/AfterExecutionAttribute.cs
@@ -1,8 +1,16 @@
namespace Telegrator.Aspects
{
+ ///
+ /// Attribute that specifies a post-execution processor to be executed after the handler.
+ /// The processor type must implement interface.
+ ///
+ /// The type of the post-processor that implements .
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
public class AfterExecutionAttribute : Attribute where T : IPostProcessor
{
+ ///
+ /// Gets the type of the post-processor.
+ ///
public Type ProcessorType => typeof(T);
}
}
diff --git a/Telegrator/Aspects/BeforeExecutionAttribute.cs b/Telegrator/Aspects/BeforeExecutionAttribute.cs
index 582b54c..0d5bbbf 100644
--- a/Telegrator/Aspects/BeforeExecutionAttribute.cs
+++ b/Telegrator/Aspects/BeforeExecutionAttribute.cs
@@ -1,8 +1,16 @@
namespace Telegrator.Aspects
{
+ ///
+ /// Attribute that specifies a pre-execution processor to be executed before the handler.
+ /// The processor type must implement interface.
+ ///
+ /// The type of the pre-processor that implements .
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
public class BeforeExecutionAttribute : Attribute where T : IPreProcessor
{
+ ///
+ /// Gets the type of the pre-processor.
+ ///
public Type ProcessorType => typeof(T);
}
}
diff --git a/Telegrator/Aspects/IPostProcessor.cs.cs b/Telegrator/Aspects/IPostProcessor.cs.cs
index 6e7eba1..7605d9e 100644
--- a/Telegrator/Aspects/IPostProcessor.cs.cs
+++ b/Telegrator/Aspects/IPostProcessor.cs.cs
@@ -6,8 +6,17 @@ using Telegrator.Handlers.Components;
namespace Telegrator.Aspects
{
+ ///
+ /// Interface for post-execution processors that are executed after handler execution.
+ /// Implement this interface to add cross-cutting concerns like logging, cleanup, or metrics collection.
+ ///
public interface IPostProcessor
{
+ ///
+ /// Executes after the handler's main execution logic.
+ ///
+ /// The handler container containing the current update and context.
+ /// A indicating the final execution result.
public Task AfterExecution(IHandlerContainer container);
}
}
diff --git a/Telegrator/Aspects/IPreProcessor.cs b/Telegrator/Aspects/IPreProcessor.cs
index d62c4d8..2a32706 100644
--- a/Telegrator/Aspects/IPreProcessor.cs
+++ b/Telegrator/Aspects/IPreProcessor.cs
@@ -6,8 +6,17 @@ using Telegrator.Handlers.Components;
namespace Telegrator.Aspects
{
+ ///
+ /// Interface for pre-execution processors that are executed before handler execution.
+ /// Implement this interface to add cross-cutting concerns like validation, logging, or authorization.
+ ///
public interface IPreProcessor
{
+ ///
+ /// Executes before the handler's main execution logic.
+ ///
+ /// The handler container containing the current update and context.
+ /// A indicating whether execution should continue or be stopped.
public Task BeforeExecution(IHandlerContainer container);
}
}
diff --git a/Telegrator/MadiatorCore/Descriptors/DescriptorAspectsSet.cs b/Telegrator/MadiatorCore/Descriptors/DescriptorAspectsSet.cs
index f852768..c356304 100644
--- a/Telegrator/MadiatorCore/Descriptors/DescriptorAspectsSet.cs
+++ b/Telegrator/MadiatorCore/Descriptors/DescriptorAspectsSet.cs
@@ -4,16 +4,40 @@ using Telegrator.Handlers.Components;
namespace Telegrator.MadiatorCore.Descriptors
{
+ ///
+ /// Manages the execution of pre and post-execution aspects for a handler.
+ /// This class coordinates between self-processing (handler implements interfaces)
+ /// and typed processing (external processor classes).
+ ///
public sealed class DescriptorAspectsSet
{
+ ///
+ /// Gets a value indicating whether the handler implements .
+ ///
public bool SelfPre { get; private set; }
+ ///
+ /// Gets a value indicating whether the handler implements .
+ ///
public bool SelfPost { get; private set; }
+ ///
+ /// Gets the type of the external pre-processor, if specified via .
+ ///
public Type? TypedPre { get; private set; }
+ ///
+ /// Gets the type of the external post-processor, if specified via .
+ ///
public Type? TypedPost { get; private set; }
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Whether the handler implements .
+ /// The type of external pre-processor, if any.
+ /// Whether the handler implements .
+ /// The type of external post-processor, if any.
public DescriptorAspectsSet(bool selfPre, Type? typedPre, bool selfPost, Type? typedPost)
{
SelfPre = selfPre;
@@ -22,6 +46,13 @@ namespace Telegrator.MadiatorCore.Descriptors
TypedPost = typedPost;
}
+ ///
+ /// Executes the pre-execution aspect for the handler.
+ ///
+ /// The handler instance.
+ /// The handler container with update context.
+ /// A indicating whether execution should continue.
+ /// Thrown when handler claims to implement but doesn't.
public async Task ExecutePre(UpdateHandlerBase handler, IHandlerContainer container)
{
if (SelfPre)
@@ -41,6 +72,13 @@ namespace Telegrator.MadiatorCore.Descriptors
return Result.Ok();
}
+ ///
+ /// Executes the post-execution aspect for the handler.
+ ///
+ /// The handler instance.
+ /// The handler container with update context.
+ /// A indicating the final execution result.
+ /// Thrown when handler claims to implement but doesn't.
public async Task ExecutePost(UpdateHandlerBase handler, IHandlerContainer container)
{
if (SelfPost)
diff --git a/Telegrator/MadiatorCore/Descriptors/HandlerDescriptor.cs b/Telegrator/MadiatorCore/Descriptors/HandlerDescriptor.cs
index 37c7e84..873513a 100644
--- a/Telegrator/MadiatorCore/Descriptors/HandlerDescriptor.cs
+++ b/Telegrator/MadiatorCore/Descriptors/HandlerDescriptor.cs
@@ -82,6 +82,10 @@ namespace Telegrator.MadiatorCore.Descriptors
protected set;
}
+ ///
+ /// Gets or sets the aspects configuration for this handler.
+ /// Contains pre and post-execution processors if the handler uses the aspect system.
+ ///
public DescriptorAspectsSet? Aspects
{
get;
diff --git a/Telegrator/MadiatorCore/Descriptors/HandlerInspector.cs b/Telegrator/MadiatorCore/Descriptors/HandlerInspector.cs
index 8d593e5..8e892db 100644
--- a/Telegrator/MadiatorCore/Descriptors/HandlerInspector.cs
+++ b/Telegrator/MadiatorCore/Descriptors/HandlerInspector.cs
@@ -82,6 +82,12 @@ namespace Telegrator.MadiatorCore.Descriptors
}
}
+ ///
+ /// Gets the aspects configuration for the specified handler type.
+ /// Inspects the handler for both self-processing (implements interfaces) and typed processing (uses attributes).
+ ///
+ /// The type of the handler to inspect.
+ /// A containing the aspects configuration.
public static DescriptorAspectsSet GetAspects(Type handlerType)
{
bool selfPre = handlerType.GetInterface(nameof(IPreProcessor)) != null;
@@ -100,7 +106,7 @@ namespace Telegrator.MadiatorCore.Descriptors
{
Attribute? postAttr = handlerType.GetCustomAttribute(typeof(AfterExecutionAttribute<>));
if (postAttr != null)
- typedPre = postAttr.GetType().GetGenericArguments()[0];
+ typedPost = postAttr.GetType().GetGenericArguments()[0];
}
return new DescriptorAspectsSet(selfPre, typedPre, selfPost, typedPost);