LoadPLugins tests
This commit is contained in:
@@ -46,21 +46,21 @@ public class PluginManager
|
||||
}
|
||||
}
|
||||
|
||||
_logger.LogInformation("Loaded {ProcessorCount} processors and {ImporterCount} importers from {AssemblyCount} assemblies",
|
||||
_processorTypes.Count,
|
||||
_importerTypes.Count,
|
||||
_logger.LogInformation("Loaded {ProcessorCount} processors and {ImporterCount} importers from {AssemblyCount} assemblies",
|
||||
_processorTypes.Count,
|
||||
_importerTypes.Count,
|
||||
dllFiles.Length); // Zmień z _plugins.Count na assemblyFiles.Length
|
||||
}
|
||||
|
||||
private void LoadPluginFromAssembly(string assemblyPath)
|
||||
{
|
||||
_logger.LogDebug("Loading assembly from: {Path}", assemblyPath); // Information -> Debug
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
var assembly = Assembly.LoadFrom(assemblyPath);
|
||||
_logger.LogDebug("Assembly loaded successfully: {Name}", assembly.FullName); // Information -> Debug
|
||||
|
||||
|
||||
foreach (var type in assembly.GetTypes())
|
||||
{
|
||||
if (typeof(IDataProcessor).IsAssignableFrom(type) && !type.IsInterface && !type.IsAbstract)
|
||||
@@ -68,7 +68,7 @@ public class PluginManager
|
||||
_processorTypes.Add(type);
|
||||
_logger.LogDebug("Registered processor: {Type}", type.Name); // Information -> Debug
|
||||
}
|
||||
|
||||
|
||||
if (typeof(IDataImporter).IsAssignableFrom(type) && !type.IsInterface && !type.IsAbstract)
|
||||
{
|
||||
_importerTypes.Add(type);
|
||||
@@ -90,7 +90,7 @@ public class PluginManager
|
||||
{
|
||||
using var scope = _serviceProvider.CreateScope();
|
||||
var instance = (IDataProcessor)ActivatorUtilities.CreateInstance(scope.ServiceProvider, type);
|
||||
|
||||
|
||||
if (instance.CanProcess(processorType))
|
||||
{
|
||||
var scopedProvider = _serviceProvider.CreateScope().ServiceProvider;
|
||||
@@ -113,7 +113,7 @@ public class PluginManager
|
||||
{
|
||||
using var scope = _serviceProvider.CreateScope();
|
||||
var instance = (IDataImporter)ActivatorUtilities.CreateInstance(scope.ServiceProvider, type);
|
||||
|
||||
|
||||
if (instance.CanImport(importerType))
|
||||
{
|
||||
var scopedProvider = _serviceProvider.CreateScope().ServiceProvider;
|
||||
@@ -132,7 +132,5 @@ public class PluginManager
|
||||
{
|
||||
return _exporters.FirstOrDefault(e => e.CanExport(exporterType));
|
||||
}
|
||||
|
||||
public IEnumerable<IDataExporter> GetAllExporters() => _exporters.AsReadOnly();
|
||||
public IEnumerable<IPlugin> GetAllPlugins() => _plugins.AsReadOnly();
|
||||
public int GetPluginsCount() => _processorTypes.Count + _importerTypes.Count + _exporters.Count;
|
||||
}
|
||||
Reference in New Issue
Block a user