2020-03-02 00:00:44 +04:00
|
|
|
using System.Collections.Concurrent;
|
2020-03-03 14:11:51 +04:00
|
|
|
using Kruzya.TelegramBot.Core.Cache;
|
2023-07-21 18:38:34 +03:00
|
|
|
using Kruzya.TelegramBot.Core.Options;
|
2020-03-02 00:00:44 +04:00
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
2023-07-21 18:38:34 +03:00
|
|
|
namespace Kruzya.TelegramBot.Core.Extensions;
|
|
|
|
|
|
|
|
|
|
public static class StartupExtension
|
2020-03-02 00:00:44 +04:00
|
|
|
{
|
2023-07-21 18:38:34 +03:00
|
|
|
public static IServiceCollection AddQueue<T>(this IServiceCollection collection)
|
|
|
|
|
=> collection.AddSingleton<ConcurrentQueue<T>>();
|
|
|
|
|
|
|
|
|
|
public static IServiceCollection AddMemoryCache<TKey, TValue>(this IServiceCollection collection)
|
|
|
|
|
=> collection.AddSingleton<MemoryCache<TKey, TValue>>();
|
|
|
|
|
|
|
|
|
|
public static IServiceCollection AddOption<T>(this IServiceCollection collection) where T : class, IOption
|
|
|
|
|
=> collection.AddScoped<T>()
|
|
|
|
|
.AddScoped<IOption, T>(s => s.GetService<T>());
|
|
|
|
|
|
2020-03-02 00:00:44 +04:00
|
|
|
}
|