[Plugin system] Move media images to dependency injection.

This commit is contained in:
2023-10-05 23:57:19 +01:00
parent 696f3ffa9a
commit 509f77036d
5 changed files with 26 additions and 25 deletions

View File

@@ -176,16 +176,16 @@ public class PluginRegisterGenerator : ISourceGenerator
if(mediaImagePlugins?.Count > 0)
{
sb.AppendLine(" public List<Type> GetAllMediaImagePlugins() => new()");
sb.AppendLine(" public void RegisterMediaImagePlugins(IServiceCollection services)");
sb.AppendLine(" {");
foreach(string plugin in mediaImagePlugins)
sb.AppendLine($" typeof({plugin}),");
sb.AppendLine($" services.AddTransient<IMediaImage, {plugin}>();");
sb.AppendLine(" };");
sb.AppendLine(" }");
}
else
sb.AppendLine(" public List<Type> GetAllMediaImagePlugins() => null;");
sb.AppendLine(" public void RegisterMediaImagePlugins(IServiceCollection services) {}");
sb.AppendLine();
@@ -394,7 +394,7 @@ public class PluginRegisterGenerator : ISourceGenerator
ByteAddressableImagePlugins.Add(plugin.Identifier.Text);
}
MediaImagePlugins.AddRange(WritableImagePlugins);
MediaImagePlugins.AddRange(WritableImagePlugins.Where(t => !ByteAddressableImagePlugins.Contains(t)));
FileSystems.AddRange(ReadOnlyFileSystems);
}