mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
32 lines
992 B
C#
32 lines
992 B
C#
using System.Reflection;
|
|
using Kruzya.TelegramBot.Core;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using West.TelegramBot.ContentStore.Service;
|
|
using Module = Kruzya.TelegramBot.Core.Module;
|
|
|
|
namespace West.TelegramBot.ContentStore;
|
|
|
|
public class ContentStore : Module
|
|
{
|
|
public readonly List<Type> MediaServiceTypes = new();
|
|
|
|
public ContentStore(Core core) : base(core)
|
|
{
|
|
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
|
|
{
|
|
foreach (var exportedType in assembly.GetExportedTypes()
|
|
.Where(t => !t.IsAbstract && t.GetInterface(nameof(IRandomMediaService)) != null))
|
|
{
|
|
MediaServiceTypes.Add(exportedType);
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void ConfigureServices(IServiceCollection services)
|
|
{
|
|
foreach (var serviceType in MediaServiceTypes)
|
|
{
|
|
services.AddSingleton(typeof(IRandomMediaService), serviceType);
|
|
}
|
|
}
|
|
} |