Files
telegram-bot/modules/ContentStore/ContentStore.cs
T
2022-11-14 00:23:36 +02:00

30 lines
917 B
C#

using Kruzya.TelegramBot.Core;
using Microsoft.Extensions.DependencyInjection;
using West.TelegramBot.ContentStore.Service;
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.AddScoped(typeof(IRandomMediaService), serviceType);
}
}
}