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