Medusa System Added

Read about the medusa system [here](https://nadekobot.readthedocs.io/en/latest/medusa/creating-a-medusa/)
This commit is contained in:
Kwoth
2022-04-16 12:44:46 +00:00
parent 3a516ab32a
commit 7cb15f5278
103 changed files with 3363 additions and 203 deletions

View File

@@ -20,16 +20,20 @@ public static class ServiceCollectionExtensions
public static IServiceCollection AddConfigServices(this IServiceCollection services)
{
var baseType = typeof(ConfigServiceBase<>);
foreach (var type in Assembly.GetCallingAssembly().ExportedTypes.Where(x => x.IsSealed))
{
if (type.BaseType?.IsGenericType == true && type.BaseType.GetGenericTypeDefinition() == baseType)
{
services.AddSingleton(type);
services.AddSingleton(x => (IConfigService)x.GetRequiredService(type));
}
}
services.Scan(x => x.FromCallingAssembly()
.AddClasses(f => f.AssignableTo(typeof(ConfigServiceBase<>)))
.AsSelfWithInterfaces());
// var baseType = typeof(ConfigServiceBase<>);
//
// foreach (var type in Assembly.GetCallingAssembly().ExportedTypes.Where(x => x.IsSealed))
// {
// if (type.BaseType?.IsGenericType == true && type.BaseType.GetGenericTypeDefinition() == baseType)
// {
// services.AddSingleton(type);
// services.AddSingleton(x => (IConfigService)x.GetRequiredService(type));
// }
// }
return services;
}