* Added missing XML summaries for new components

This commit is contained in:
2025-08-03 01:59:13 +04:00
parent b14d848537
commit 34ac0231d5
8 changed files with 85 additions and 2 deletions
+2 -1
View File
@@ -360,4 +360,5 @@ MigrationBackup/
.ionide/ .ionide/
# Fody - auto-generated XML schema # Fody - auto-generated XML schema
FodyWeavers.xsd FodyWeavers.xsd
/GETTING_STARTED.md
@@ -1,8 +1,16 @@
namespace Telegrator.Aspects namespace Telegrator.Aspects
{ {
/// <summary>
/// Attribute that specifies a post-execution processor to be executed after the handler.
/// The processor type must implement <see cref="IPostProcessor"/> interface.
/// </summary>
/// <typeparam name="T">The type of the post-processor that implements <see cref="IPostProcessor"/>.</typeparam>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
public class AfterExecutionAttribute<T> : Attribute where T : IPostProcessor public class AfterExecutionAttribute<T> : Attribute where T : IPostProcessor
{ {
/// <summary>
/// Gets the type of the post-processor.
/// </summary>
public Type ProcessorType => typeof(T); public Type ProcessorType => typeof(T);
} }
} }
@@ -1,8 +1,16 @@
namespace Telegrator.Aspects namespace Telegrator.Aspects
{ {
/// <summary>
/// Attribute that specifies a pre-execution processor to be executed before the handler.
/// The processor type must implement <see cref="IPreProcessor"/> interface.
/// </summary>
/// <typeparam name="T">The type of the pre-processor that implements <see cref="IPreProcessor"/>.</typeparam>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
public class BeforeExecutionAttribute<T> : Attribute where T : IPreProcessor public class BeforeExecutionAttribute<T> : Attribute where T : IPreProcessor
{ {
/// <summary>
/// Gets the type of the pre-processor.
/// </summary>
public Type ProcessorType => typeof(T); public Type ProcessorType => typeof(T);
} }
} }
+9
View File
@@ -6,8 +6,17 @@ using Telegrator.Handlers.Components;
namespace Telegrator.Aspects namespace Telegrator.Aspects
{ {
/// <summary>
/// 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.
/// </summary>
public interface IPostProcessor public interface IPostProcessor
{ {
/// <summary>
/// Executes after the handler's main execution logic.
/// </summary>
/// <param name="container">The handler container containing the current update and context.</param>
/// <returns>A <see cref="Result"/> indicating the final execution result.</returns>
public Task<Result> AfterExecution(IHandlerContainer container); public Task<Result> AfterExecution(IHandlerContainer container);
} }
} }
+9
View File
@@ -6,8 +6,17 @@ using Telegrator.Handlers.Components;
namespace Telegrator.Aspects namespace Telegrator.Aspects
{ {
/// <summary>
/// Interface for pre-execution processors that are executed before handler execution.
/// Implement this interface to add cross-cutting concerns like validation, logging, or authorization.
/// </summary>
public interface IPreProcessor public interface IPreProcessor
{ {
/// <summary>
/// Executes before the handler's main execution logic.
/// </summary>
/// <param name="container">The handler container containing the current update and context.</param>
/// <returns>A <see cref="Result"/> indicating whether execution should continue or be stopped.</returns>
public Task<Result> BeforeExecution(IHandlerContainer container); public Task<Result> BeforeExecution(IHandlerContainer container);
} }
} }
@@ -4,16 +4,40 @@ using Telegrator.Handlers.Components;
namespace Telegrator.MadiatorCore.Descriptors namespace Telegrator.MadiatorCore.Descriptors
{ {
/// <summary>
/// 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).
/// </summary>
public sealed class DescriptorAspectsSet public sealed class DescriptorAspectsSet
{ {
/// <summary>
/// Gets a value indicating whether the handler implements <see cref="IPreProcessor"/>.
/// </summary>
public bool SelfPre { get; private set; } public bool SelfPre { get; private set; }
/// <summary>
/// Gets a value indicating whether the handler implements <see cref="IPostProcessor"/>.
/// </summary>
public bool SelfPost { get; private set; } public bool SelfPost { get; private set; }
/// <summary>
/// Gets the type of the external pre-processor, if specified via <see cref="BeforeExecutionAttribute{T}"/>.
/// </summary>
public Type? TypedPre { get; private set; } public Type? TypedPre { get; private set; }
/// <summary>
/// Gets the type of the external post-processor, if specified via <see cref="AfterExecutionAttribute{T}"/>.
/// </summary>
public Type? TypedPost { get; private set; } public Type? TypedPost { get; private set; }
/// <summary>
/// Initializes a new instance of the <see cref="DescriptorAspectsSet"/> class.
/// </summary>
/// <param name="selfPre">Whether the handler implements <see cref="IPreProcessor"/>.</param>
/// <param name="typedPre">The type of external pre-processor, if any.</param>
/// <param name="selfPost">Whether the handler implements <see cref="IPostProcessor"/>.</param>
/// <param name="typedPost">The type of external post-processor, if any.</param>
public DescriptorAspectsSet(bool selfPre, Type? typedPre, bool selfPost, Type? typedPost) public DescriptorAspectsSet(bool selfPre, Type? typedPre, bool selfPost, Type? typedPost)
{ {
SelfPre = selfPre; SelfPre = selfPre;
@@ -22,6 +46,13 @@ namespace Telegrator.MadiatorCore.Descriptors
TypedPost = typedPost; TypedPost = typedPost;
} }
/// <summary>
/// Executes the pre-execution aspect for the handler.
/// </summary>
/// <param name="handler">The handler instance.</param>
/// <param name="container">The handler container with update context.</param>
/// <returns>A <see cref="Result"/> indicating whether execution should continue.</returns>
/// <exception cref="InvalidOperationException">Thrown when handler claims to implement <see cref="IPreProcessor"/> but doesn't.</exception>
public async Task<Result> ExecutePre(UpdateHandlerBase handler, IHandlerContainer container) public async Task<Result> ExecutePre(UpdateHandlerBase handler, IHandlerContainer container)
{ {
if (SelfPre) if (SelfPre)
@@ -41,6 +72,13 @@ namespace Telegrator.MadiatorCore.Descriptors
return Result.Ok(); return Result.Ok();
} }
/// <summary>
/// Executes the post-execution aspect for the handler.
/// </summary>
/// <param name="handler">The handler instance.</param>
/// <param name="container">The handler container with update context.</param>
/// <returns>A <see cref="Result"/> indicating the final execution result.</returns>
/// <exception cref="InvalidOperationException">Thrown when handler claims to implement <see cref="IPostProcessor"/> but doesn't.</exception>
public async Task<Result> ExecutePost(UpdateHandlerBase handler, IHandlerContainer container) public async Task<Result> ExecutePost(UpdateHandlerBase handler, IHandlerContainer container)
{ {
if (SelfPost) if (SelfPost)
@@ -82,6 +82,10 @@ namespace Telegrator.MadiatorCore.Descriptors
protected set; protected set;
} }
/// <summary>
/// Gets or sets the aspects configuration for this handler.
/// Contains pre and post-execution processors if the handler uses the aspect system.
/// </summary>
public DescriptorAspectsSet? Aspects public DescriptorAspectsSet? Aspects
{ {
get; get;
@@ -82,6 +82,12 @@ namespace Telegrator.MadiatorCore.Descriptors
} }
} }
/// <summary>
/// Gets the aspects configuration for the specified handler type.
/// Inspects the handler for both self-processing (implements interfaces) and typed processing (uses attributes).
/// </summary>
/// <param name="handlerType">The type of the handler to inspect.</param>
/// <returns>A <see cref="DescriptorAspectsSet"/> containing the aspects configuration.</returns>
public static DescriptorAspectsSet GetAspects(Type handlerType) public static DescriptorAspectsSet GetAspects(Type handlerType)
{ {
bool selfPre = handlerType.GetInterface(nameof(IPreProcessor)) != null; bool selfPre = handlerType.GetInterface(nameof(IPreProcessor)) != null;
@@ -100,7 +106,7 @@ namespace Telegrator.MadiatorCore.Descriptors
{ {
Attribute? postAttr = handlerType.GetCustomAttribute(typeof(AfterExecutionAttribute<>)); Attribute? postAttr = handlerType.GetCustomAttribute(typeof(AfterExecutionAttribute<>));
if (postAttr != null) if (postAttr != null)
typedPre = postAttr.GetType().GetGenericArguments()[0]; typedPost = postAttr.GetType().GetGenericArguments()[0];
} }
return new DescriptorAspectsSet(selfPre, typedPre, selfPost, typedPost); return new DescriptorAspectsSet(selfPre, typedPre, selfPost, typedPost);