From 899243c62b88e012873122393ee3c1ff1adb6f5d Mon Sep 17 00:00:00 2001 From: Rikitav Date: Mon, 9 Mar 2026 13:10:49 +0400 Subject: [PATCH] * Added default state storage registering * Added extension method for replacing default state storage --- .../Telegartor.RedisStateStorage.csproj | 6 +++--- .../Telegrator.Hosting.Web.csproj | 2 +- src/Telegrator.Hosting/Telegrator.Hosting.csproj | 2 +- src/Telegrator.Hosting/TypesExtensions.cs | 15 +++++++++++++++ src/Telegrator/Telegrator.csproj | 4 ++-- 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/Telegartor.RedisStateStorage/Telegartor.RedisStateStorage.csproj b/src/Telegartor.RedisStateStorage/Telegartor.RedisStateStorage.csproj index bdf4782..94d709c 100644 --- a/src/Telegartor.RedisStateStorage/Telegartor.RedisStateStorage.csproj +++ b/src/Telegartor.RedisStateStorage/Telegartor.RedisStateStorage.csproj @@ -1,7 +1,7 @@  - netstandard2.1 + netstandard2.0 enable enable latest @@ -15,7 +15,7 @@ True Telegrator.RedisStateStorage - 1.16.4 + 1.16.5 Rikitav Tim4ik Rikitav Tim4ik https://github.com/Rikitav/Telegrator @@ -31,7 +31,7 @@ - + diff --git a/src/Telegrator.Hosting.Web/Telegrator.Hosting.Web.csproj b/src/Telegrator.Hosting.Web/Telegrator.Hosting.Web.csproj index 7be0df7..6084a91 100644 --- a/src/Telegrator.Hosting.Web/Telegrator.Hosting.Web.csproj +++ b/src/Telegrator.Hosting.Web/Telegrator.Hosting.Web.csproj @@ -15,7 +15,7 @@ True Telegrator.Hosting.Web - 1.16.4 + 1.16.5 Rikitav Tim4ik Rikitav Tim4ik https://github.com/Rikitav/Telegrator diff --git a/src/Telegrator.Hosting/Telegrator.Hosting.csproj b/src/Telegrator.Hosting/Telegrator.Hosting.csproj index 577613a..2e01884 100644 --- a/src/Telegrator.Hosting/Telegrator.Hosting.csproj +++ b/src/Telegrator.Hosting/Telegrator.Hosting.csproj @@ -15,7 +15,7 @@ True Telegrator.Hosting - 1.16.4 + 1.16.5 Rikitav Tim4ik Rikitav Tim4ik https://github.com/Rikitav/Telegrator diff --git a/src/Telegrator.Hosting/TypesExtensions.cs b/src/Telegrator.Hosting/TypesExtensions.cs index 1ecc7b5..2612e0b 100644 --- a/src/Telegrator.Hosting/TypesExtensions.cs +++ b/src/Telegrator.Hosting/TypesExtensions.cs @@ -11,10 +11,12 @@ using Telegram.Bot.Types; using Telegram.Bot.Types.Enums; using Telegrator.Core; using Telegrator.Core.Descriptors; +using Telegrator.Core.States; using Telegrator.Hosting; using Telegrator.Logging; using Telegrator.Polling; using Telegrator.Providers; +using Telegrator.States; namespace Telegrator; @@ -112,6 +114,18 @@ public static class HostBuilderExtensions /// public static class ServicesCollectionExtensions { + /// + /// Registers service + /// + /// + /// + /// + public static IServiceCollection AddStateStorage(this IServiceCollection services) where TStorage : IStateStorage + { + services.Replace(new ServiceDescriptor(typeof(IStateStorage), typeof(TStorage), ServiceLifetime.Singleton)); + return services; + } + /// /// Registers default services /// @@ -124,6 +138,7 @@ public static class ServicesCollectionExtensions services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); + services.AddSingleton(); return services; } diff --git a/src/Telegrator/Telegrator.csproj b/src/Telegrator/Telegrator.csproj index 21ecf6a..00a2c30 100644 --- a/src/Telegrator/Telegrator.csproj +++ b/src/Telegrator/Telegrator.csproj @@ -1,7 +1,7 @@  - netstandard2.1 + netstandard2.0 enable enable latest @@ -14,7 +14,7 @@ True Telegrator : Telegram.Bot mediator framework - 1.16.4 + 1.16.5 Rikitav Tim4ik Rikitav Tim4ik https://github.com/Rikitav/Telegrator