* Renamed DescribeHandlerInfo to DescribedHandlerDescriptor
* Added AwaitResult and ReportResult methods to DescribedHandlerDescriptor * Moved DontCollectAttribute and MightAwaitAttribute to Annotations namespace * Rewrote UpdateRouter and UpdateHandlersPool * Fixed Synchronous handlers routing bug * Code cleanup
This commit is contained in:
@@ -37,7 +37,7 @@ namespace Telegrator.Handlers.Building
|
||||
/// </summary>
|
||||
/// <param name="describedHandler">The handler information containing the update.</param>
|
||||
/// <returns>An empty handler container.</returns>
|
||||
public IHandlerContainer CreateContainer(DescribedHandlerInfo describedHandler)
|
||||
public IHandlerContainer CreateContainer(DescribedHandlerDescriptor describedHandler)
|
||||
{
|
||||
HandlingUpdate = describedHandler.HandlingUpdate;
|
||||
return new EmptyHandlerContainer();
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace Telegrator.Handlers.Components
|
||||
/// </summary>
|
||||
/// <param name="handlerInfo">The handler descriptor info.</param>
|
||||
/// <returns>The created handler container.</returns>
|
||||
public virtual IHandlerContainer CreateContainer(DescribedHandlerInfo handlerInfo)
|
||||
public virtual IHandlerContainer CreateContainer(DescribedHandlerDescriptor handlerInfo)
|
||||
{
|
||||
return new HandlerContainer<TUpdate>(handlerInfo);
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace Telegrator.Handlers.Components
|
||||
/// <param name="handlerInfo">The handler information.</param>
|
||||
/// <returns>A handler container for this branching handler.</returns>
|
||||
/// <exception cref="Exception">Thrown when the awaiting provider is not of the expected type.</exception>
|
||||
public override IHandlerContainer CreateContainer(DescribedHandlerInfo handlerInfo)
|
||||
public override IHandlerContainer CreateContainer(DescribedHandlerDescriptor handlerInfo)
|
||||
{
|
||||
return new HandlerContainer<TUpdate>(handlerInfo);
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ namespace Telegrator.Handlers.Components
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="IHandlerContainer"/> for the specified awaiting provider and handler info.
|
||||
/// </summary>
|
||||
/// <param name="handlerInfo">The <see cref="DescribedHandlerInfo"/> for the handler.</param>
|
||||
/// <param name="handlerInfo">The <see cref="DescribedHandlerDescriptor"/> for the handler.</param>
|
||||
/// <returns>A new <see cref="IHandlerContainer"/> instance.</returns>
|
||||
public IHandlerContainer CreateContainer(DescribedHandlerInfo handlerInfo);
|
||||
public IHandlerContainer CreateContainer(DescribedHandlerDescriptor handlerInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public interface IUpdateHandlerBase : IDisposable
|
||||
/// <param name="described"></param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
|
||||
Task<Result> Execute(DescribedHandlerInfo described, CancellationToken cancellationToken = default);
|
||||
Task<Result> Execute(DescribedHandlerDescriptor described, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Handles failed filters during handler describing.
|
||||
|
||||
@@ -22,13 +22,13 @@ namespace Telegrator.Handlers.Components
|
||||
public HandlerLifetimeToken LifetimeToken { get; } = new HandlerLifetimeToken();
|
||||
|
||||
/// <inheritdoc cref="Result.Ok"/>
|
||||
public Result Ok => Result.Ok();
|
||||
public static Result Ok => Result.Ok();
|
||||
|
||||
/// <inheritdoc cref="Result.Fault"/>
|
||||
public Result Fault => Result.Fault();
|
||||
public static Result Fault => Result.Fault();
|
||||
|
||||
/// <inheritdoc cref="Result.Next"/>
|
||||
public Result Next => Result.Next();
|
||||
public static Result Next => Result.Next();
|
||||
|
||||
/// <summary>
|
||||
/// Executes the handler logic and marks the lifetime as ended after execution.
|
||||
@@ -36,7 +36,7 @@ namespace Telegrator.Handlers.Components
|
||||
/// <param name="described"></param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
|
||||
public async Task<Result> Execute(DescribedHandlerInfo described, CancellationToken cancellationToken = default)
|
||||
public async Task<Result> Execute(DescribedHandlerDescriptor described, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (LifetimeToken.IsEnded)
|
||||
throw new Exception();
|
||||
@@ -125,7 +125,7 @@ namespace Telegrator.Handlers.Components
|
||||
}
|
||||
}
|
||||
|
||||
internal IHandlerContainer GetContainer(DescribedHandlerInfo handlerInfo)
|
||||
internal IHandlerContainer GetContainer(DescribedHandlerDescriptor handlerInfo)
|
||||
{
|
||||
if (this is IHandlerContainerFactory handlerDefainedContainerFactory)
|
||||
return handlerDefainedContainerFactory.CreateContainer(handlerInfo);
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Telegrator.Handlers
|
||||
/// Initializes new instance of <see cref="HandlerContainer{TUpdate}"/>
|
||||
/// </summary>
|
||||
/// <param name="handlerInfo"></param>
|
||||
public HandlerContainer(DescribedHandlerInfo handlerInfo)
|
||||
public HandlerContainer(DescribedHandlerDescriptor handlerInfo)
|
||||
{
|
||||
ActualUpdate = handlerInfo.HandlingUpdate.GetActualUpdateObject<TUpdate>();
|
||||
HandlingUpdate = handlerInfo.HandlingUpdate;
|
||||
|
||||
@@ -197,7 +197,7 @@ namespace Telegrator.Handlers
|
||||
int? directMessageTopicId = null,
|
||||
SuggestedPostParameters? suggestedPostParameters = null,
|
||||
CancellationToken cancellationToken = default)
|
||||
=> await Container.Response(
|
||||
=> await Container.Responce(
|
||||
text, parseMode, replyParameters,
|
||||
replyMarkup, linkPreviewOptions,
|
||||
messageThreadId, entities,
|
||||
|
||||
Reference in New Issue
Block a user