| | | 1 | | using Microsoft.Extensions.DependencyInjection; |
| | | 2 | | using Microsoft.Extensions.DependencyInjection.Extensions; |
| | | 3 | | using TeleFlow.Framework.Middleware; |
| | | 4 | | using TeleFlow.Framework.States; |
| | | 5 | | |
| | | 6 | | namespace TeleFlow.Storage.Memory; |
| | | 7 | | |
| | | 8 | | public static class MemoryStateServiceCollectionExtensions |
| | | 9 | | { |
| | | 10 | | public static IServiceCollection AddMemoryStateStorage(this IServiceCollection services) |
| | | 11 | | { |
| | 17 | 12 | | ArgumentNullException.ThrowIfNull(services); |
| | | 13 | | |
| | 17 | 14 | | services.TryAddSingleton<IStateStore, MemoryStateStore>(); |
| | 17 | 15 | | services.TryAddSingleton<IStateDataStore, MemoryStateDataStore>(); |
| | 17 | 16 | | services.TryAddSingleton<IStateDataSerializer, JsonStateDataSerializer>(); |
| | 17 | 17 | | services.TryAddSingleton<IStateHistoryStore, MemoryStateHistoryStore>(); |
| | 17 | 18 | | services.TryAddSingleton<IStateStorageKeyBuilder, DefaultStateStorageKeyBuilder>(); |
| | 17 | 19 | | services.AddUpdateMiddleware<UpdateStateMiddleware>(); |
| | | 20 | | |
| | 17 | 21 | | return services; |
| | | 22 | | } |
| | | 23 | | } |