mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Use Array.Empty
This commit is contained in:
@@ -62,8 +62,7 @@ public sealed class FiltersList
|
|||||||
foreach(Type type in assembly.GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IFilter))))
|
foreach(Type type in assembly.GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IFilter))))
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var filter = (IFilter)type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[]
|
var filter = (IFilter)type.GetConstructor(Type.EmptyTypes)?.Invoke(Array.Empty<object>());
|
||||||
{});
|
|
||||||
|
|
||||||
if(filter != null &&
|
if(filter != null &&
|
||||||
!Filters.ContainsKey(filter.Name.ToLower()))
|
!Filters.ContainsKey(filter.Name.ToLower()))
|
||||||
@@ -90,8 +89,7 @@ public sealed class FiltersList
|
|||||||
if(!filter.Identify(path))
|
if(!filter.Identify(path))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var foundFilter = (IFilter)filter.GetType().GetConstructor(Type.EmptyTypes)?.Invoke(new object[]
|
var foundFilter = (IFilter)filter.GetType().GetConstructor(Type.EmptyTypes)?.Invoke(Array.Empty<object>());
|
||||||
{});
|
|
||||||
|
|
||||||
if(foundFilter?.Open(path) == ErrorNumber.NoError)
|
if(foundFilter?.Open(path) == ErrorNumber.NoError)
|
||||||
return foundFilter;
|
return foundFilter;
|
||||||
|
|||||||
@@ -90,67 +90,56 @@ public class PluginBase
|
|||||||
public void AddPlugins(IPluginRegister pluginRegister)
|
public void AddPlugins(IPluginRegister pluginRegister)
|
||||||
{
|
{
|
||||||
foreach(Type type in pluginRegister.GetAllChecksumPlugins() ?? Enumerable.Empty<Type>())
|
foreach(Type type in pluginRegister.GetAllChecksumPlugins() ?? Enumerable.Empty<Type>())
|
||||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[]
|
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(Array.Empty<object>()) is IChecksum plugin)
|
||||||
{}) is IChecksum plugin)
|
|
||||||
Checksums.Add(plugin);
|
Checksums.Add(plugin);
|
||||||
|
|
||||||
foreach(Type type in pluginRegister.GetAllFilesystemPlugins() ?? Enumerable.Empty<Type>())
|
foreach(Type type in pluginRegister.GetAllFilesystemPlugins() ?? Enumerable.Empty<Type>())
|
||||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[]
|
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(Array.Empty<object>()) is IFilesystem plugin &&
|
||||||
{}) is IFilesystem plugin &&
|
|
||||||
!PluginsList.ContainsKey(plugin.Name.ToLower()))
|
!PluginsList.ContainsKey(plugin.Name.ToLower()))
|
||||||
PluginsList.Add(plugin.Name.ToLower(), plugin);
|
PluginsList.Add(plugin.Name.ToLower(), plugin);
|
||||||
|
|
||||||
foreach(Type type in pluginRegister.GetAllFilterPlugins() ?? Enumerable.Empty<Type>())
|
foreach(Type type in pluginRegister.GetAllFilterPlugins() ?? Enumerable.Empty<Type>())
|
||||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[]
|
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(Array.Empty<object>()) is IFilter plugin &&
|
||||||
{}) is IFilter plugin &&
|
|
||||||
!Filters.ContainsKey(plugin.Name.ToLower()))
|
!Filters.ContainsKey(plugin.Name.ToLower()))
|
||||||
Filters.Add(plugin.Name.ToLower(), plugin);
|
Filters.Add(plugin.Name.ToLower(), plugin);
|
||||||
|
|
||||||
foreach(Type type in pluginRegister.GetAllFloppyImagePlugins() ?? Enumerable.Empty<Type>())
|
foreach(Type type in pluginRegister.GetAllFloppyImagePlugins() ?? Enumerable.Empty<Type>())
|
||||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[]
|
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(Array.Empty<object>()) is IFloppyImage plugin &&
|
||||||
{}) is IFloppyImage plugin &&
|
|
||||||
!FloppyImages.ContainsKey(plugin.Name.ToLower()))
|
!FloppyImages.ContainsKey(plugin.Name.ToLower()))
|
||||||
FloppyImages.Add(plugin.Name.ToLower(), plugin);
|
FloppyImages.Add(plugin.Name.ToLower(), plugin);
|
||||||
|
|
||||||
foreach(Type type in pluginRegister.GetAllMediaImagePlugins() ?? Enumerable.Empty<Type>())
|
foreach(Type type in pluginRegister.GetAllMediaImagePlugins() ?? Enumerable.Empty<Type>())
|
||||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[]
|
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(Array.Empty<object>()) is IMediaImage plugin &&
|
||||||
{}) is IMediaImage plugin &&
|
|
||||||
!ImagePluginsList.ContainsKey(plugin.Name.ToLower()))
|
!ImagePluginsList.ContainsKey(plugin.Name.ToLower()))
|
||||||
ImagePluginsList.Add(plugin.Name.ToLower(), plugin);
|
ImagePluginsList.Add(plugin.Name.ToLower(), plugin);
|
||||||
|
|
||||||
foreach(Type type in pluginRegister.GetAllPartitionPlugins() ?? Enumerable.Empty<Type>())
|
foreach(Type type in pluginRegister.GetAllPartitionPlugins() ?? Enumerable.Empty<Type>())
|
||||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[]
|
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(Array.Empty<object>()) is IPartition plugin &&
|
||||||
{}) is IPartition plugin &&
|
|
||||||
!PartPluginsList.ContainsKey(plugin.Name.ToLower()))
|
!PartPluginsList.ContainsKey(plugin.Name.ToLower()))
|
||||||
PartPluginsList.Add(plugin.Name.ToLower(), plugin);
|
PartPluginsList.Add(plugin.Name.ToLower(), plugin);
|
||||||
|
|
||||||
foreach(Type type in pluginRegister.GetAllReadOnlyFilesystemPlugins() ?? Enumerable.Empty<Type>())
|
foreach(Type type in pluginRegister.GetAllReadOnlyFilesystemPlugins() ?? Enumerable.Empty<Type>())
|
||||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[]
|
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(Array.Empty<object>()) is IReadOnlyFilesystem plugin &&
|
||||||
{}) is IReadOnlyFilesystem plugin &&
|
|
||||||
!ReadOnlyFilesystems.ContainsKey(plugin.Name.ToLower()))
|
!ReadOnlyFilesystems.ContainsKey(plugin.Name.ToLower()))
|
||||||
ReadOnlyFilesystems.Add(plugin.Name.ToLower(), plugin);
|
ReadOnlyFilesystems.Add(plugin.Name.ToLower(), plugin);
|
||||||
|
|
||||||
foreach(Type type in pluginRegister.GetAllWritableFloppyImagePlugins() ?? Enumerable.Empty<Type>())
|
foreach(Type type in pluginRegister.GetAllWritableFloppyImagePlugins() ?? Enumerable.Empty<Type>())
|
||||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[]
|
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(Array.Empty<object>()) is IWritableFloppyImage plugin &&
|
||||||
{}) is IWritableFloppyImage plugin &&
|
|
||||||
!WritableFloppyImages.ContainsKey(plugin.Name.ToLower()))
|
!WritableFloppyImages.ContainsKey(plugin.Name.ToLower()))
|
||||||
WritableFloppyImages.Add(plugin.Name.ToLower(), plugin);
|
WritableFloppyImages.Add(plugin.Name.ToLower(), plugin);
|
||||||
|
|
||||||
foreach(Type type in pluginRegister.GetAllWritableImagePlugins() ?? Enumerable.Empty<Type>())
|
foreach(Type type in pluginRegister.GetAllWritableImagePlugins() ?? Enumerable.Empty<Type>())
|
||||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[]
|
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(Array.Empty<object>()) is IBaseWritableImage plugin &&
|
||||||
{}) is IBaseWritableImage plugin &&
|
|
||||||
!WritableImages.ContainsKey(plugin.Name.ToLower()))
|
!WritableImages.ContainsKey(plugin.Name.ToLower()))
|
||||||
WritableImages.Add(plugin.Name.ToLower(), plugin);
|
WritableImages.Add(plugin.Name.ToLower(), plugin);
|
||||||
|
|
||||||
foreach(Type type in pluginRegister.GetAllArchivePlugins() ?? Enumerable.Empty<Type>())
|
foreach(Type type in pluginRegister.GetAllArchivePlugins() ?? Enumerable.Empty<Type>())
|
||||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[]
|
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(Array.Empty<object>()) is IArchive plugin &&
|
||||||
{}) is IArchive plugin &&
|
|
||||||
!Archives.ContainsKey(plugin.Name.ToLower()))
|
!Archives.ContainsKey(plugin.Name.ToLower()))
|
||||||
Archives.Add(plugin.Name.ToLower(), plugin);
|
Archives.Add(plugin.Name.ToLower(), plugin);
|
||||||
|
|
||||||
foreach(Type type in pluginRegister.GetAllByteAddressablePlugins() ?? Enumerable.Empty<Type>())
|
foreach(Type type in pluginRegister.GetAllByteAddressablePlugins() ?? Enumerable.Empty<Type>())
|
||||||
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[]
|
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(Array.Empty<object>()) is IByteAddressableImage plugin &&
|
||||||
{}) is IByteAddressableImage plugin &&
|
|
||||||
!ByteAddressableImages.ContainsKey(plugin.Name.ToLower()))
|
!ByteAddressableImages.ContainsKey(plugin.Name.ToLower()))
|
||||||
ByteAddressableImages.Add(plugin.Name.ToLower(), plugin);
|
ByteAddressableImages.Add(plugin.Name.ToLower(), plugin);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user