From 29c3b8df810d6757b6dc24c051799a1734cb6e4e Mon Sep 17 00:00:00 2001 From: Rikitav Date: Fri, 6 Mar 2026 15:10:41 +0400 Subject: [PATCH] Added little skip for results returning, Ok, Fault and Next properties to UpdateHandlerBase, now instaed of 'return Result.Ok();' you can just type 'return Ok;' --- Telegrator/Handlers/Components/UpdateHandlerBase.cs | 9 +++++++++ Telegrator/Result.cs | 10 +++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Telegrator/Handlers/Components/UpdateHandlerBase.cs b/Telegrator/Handlers/Components/UpdateHandlerBase.cs index 8f8affd..a4acb7c 100644 --- a/Telegrator/Handlers/Components/UpdateHandlerBase.cs +++ b/Telegrator/Handlers/Components/UpdateHandlerBase.cs @@ -21,6 +21,15 @@ namespace Telegrator.Handlers.Components /// public HandlerLifetimeToken LifetimeToken { get; } = new HandlerLifetimeToken(); + /// + public Result Ok => Result.Ok(); + + /// + public Result Fault => Result.Fault(); + + /// + public Result Next => Result.Next(); + /// /// Executes the handler logic and marks the lifetime as ended after execution. /// diff --git a/Telegrator/Result.cs b/Telegrator/Result.cs index 86846b0..6b987a4 100644 --- a/Telegrator/Result.cs +++ b/Telegrator/Result.cs @@ -12,6 +12,10 @@ namespace Telegrator /// public sealed class Result { + private static readonly Result ok = new Result(true, false, null); + private static readonly Result fault = new Result(false, false, null); + private static readonly Result next = new Result(true, true, null); + /// /// Is result positive /// @@ -44,7 +48,7 @@ namespace Telegrator /// /// public static Result Ok() - => new Result(true, false, null); + => ok; /// /// Represents 'fault' or 'error'. Use cases: @@ -55,7 +59,7 @@ namespace Telegrator /// /// public static Result Fault() - => new Result(false, false, null); + => fault; /// /// Represents 'continue'. Use cases: @@ -66,7 +70,7 @@ namespace Telegrator /// /// public static Result Next() - => new Result(true, true, null); + => next; /// /// Represents 'chain'. Use cases: