mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
[Plugin system] Move floppy images to dependency injection.
This commit is contained in:
Submodule Aaru.CommonTypes updated: f5de3435e5...c6506f7b89
@@ -161,16 +161,16 @@ public class PluginRegisterGenerator : ISourceGenerator
|
||||
|
||||
if(floppyImagePlugins?.Count > 0)
|
||||
{
|
||||
sb.AppendLine(" public List<Type> GetAllFloppyImagePlugins() => new()");
|
||||
sb.AppendLine(" public void RegisterFloppyImagePlugins(IServiceCollection services)");
|
||||
sb.AppendLine(" {");
|
||||
|
||||
foreach(string plugin in floppyImagePlugins)
|
||||
sb.AppendLine($" typeof({plugin}),");
|
||||
sb.AppendLine($" services.AddTransient<IFloppyImage, {plugin}>();");
|
||||
|
||||
sb.AppendLine(" };");
|
||||
sb.AppendLine(" }");
|
||||
}
|
||||
else
|
||||
sb.AppendLine(" public List<Type> GetAllFloppyImagePlugins() => null;");
|
||||
sb.AppendLine(" public void RegisterFloppyImagePlugins(IServiceCollection services) {}");
|
||||
|
||||
sb.AppendLine();
|
||||
|
||||
|
||||
@@ -76,16 +76,16 @@ public sealed class PluginsViewModel : ViewModelBase
|
||||
});
|
||||
}
|
||||
|
||||
foreach(Type imageType in PluginRegister.Singleton.FloppyImages.Values)
|
||||
foreach(IFloppyImage floppyImage in PluginRegister.Singleton.FloppyImages.Values)
|
||||
{
|
||||
if(Activator.CreateInstance(imageType) is not IFloppyImage floppyImage)
|
||||
if(floppyImage is null)
|
||||
continue;
|
||||
|
||||
FloppyImages.Add(new PluginModel
|
||||
{
|
||||
Name = floppyImage.Name,
|
||||
Uuid = floppyImage.Id,
|
||||
Version = Assembly.GetAssembly(imageType)?.GetName().Version?.ToString(),
|
||||
Version = Assembly.GetAssembly(floppyImage.GetType())?.GetName().Version?.ToString(),
|
||||
Author = floppyImage.Author
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user