diff --git a/Filters.cs b/Filters.cs index 43c91c6..ad7a15d 100644 --- a/Filters.cs +++ b/Filters.cs @@ -62,8 +62,7 @@ public sealed class FiltersList foreach(Type type in assembly.GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IFilter)))) try { - var filter = (IFilter)type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] - {}); + var filter = (IFilter)type.GetConstructor(Type.EmptyTypes)?.Invoke(Array.Empty()); if(filter != null && !Filters.ContainsKey(filter.Name.ToLower())) @@ -90,8 +89,7 @@ public sealed class FiltersList if(!filter.Identify(path)) continue; - var foundFilter = (IFilter)filter.GetType().GetConstructor(Type.EmptyTypes)?.Invoke(new object[] - {}); + var foundFilter = (IFilter)filter.GetType().GetConstructor(Type.EmptyTypes)?.Invoke(Array.Empty()); if(foundFilter?.Open(path) == ErrorNumber.NoError) return foundFilter; diff --git a/PluginBase.cs b/PluginBase.cs index cbe2c22..e848273 100644 --- a/PluginBase.cs +++ b/PluginBase.cs @@ -90,67 +90,56 @@ public class PluginBase public void AddPlugins(IPluginRegister pluginRegister) { foreach(Type type in pluginRegister.GetAllChecksumPlugins() ?? Enumerable.Empty()) - if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] - {}) is IChecksum plugin) + if(type.GetConstructor(Type.EmptyTypes)?.Invoke(Array.Empty()) is IChecksum plugin) Checksums.Add(plugin); foreach(Type type in pluginRegister.GetAllFilesystemPlugins() ?? Enumerable.Empty()) - if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] - {}) is IFilesystem plugin && + if(type.GetConstructor(Type.EmptyTypes)?.Invoke(Array.Empty()) is IFilesystem plugin && !PluginsList.ContainsKey(plugin.Name.ToLower())) PluginsList.Add(plugin.Name.ToLower(), plugin); foreach(Type type in pluginRegister.GetAllFilterPlugins() ?? Enumerable.Empty()) - if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] - {}) is IFilter plugin && + if(type.GetConstructor(Type.EmptyTypes)?.Invoke(Array.Empty()) is IFilter plugin && !Filters.ContainsKey(plugin.Name.ToLower())) Filters.Add(plugin.Name.ToLower(), plugin); foreach(Type type in pluginRegister.GetAllFloppyImagePlugins() ?? Enumerable.Empty()) - if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] - {}) is IFloppyImage plugin && + if(type.GetConstructor(Type.EmptyTypes)?.Invoke(Array.Empty()) is IFloppyImage plugin && !FloppyImages.ContainsKey(plugin.Name.ToLower())) FloppyImages.Add(plugin.Name.ToLower(), plugin); foreach(Type type in pluginRegister.GetAllMediaImagePlugins() ?? Enumerable.Empty()) - if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] - {}) is IMediaImage plugin && + if(type.GetConstructor(Type.EmptyTypes)?.Invoke(Array.Empty()) is IMediaImage plugin && !ImagePluginsList.ContainsKey(plugin.Name.ToLower())) ImagePluginsList.Add(plugin.Name.ToLower(), plugin); foreach(Type type in pluginRegister.GetAllPartitionPlugins() ?? Enumerable.Empty()) - if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] - {}) is IPartition plugin && + if(type.GetConstructor(Type.EmptyTypes)?.Invoke(Array.Empty()) is IPartition plugin && !PartPluginsList.ContainsKey(plugin.Name.ToLower())) PartPluginsList.Add(plugin.Name.ToLower(), plugin); foreach(Type type in pluginRegister.GetAllReadOnlyFilesystemPlugins() ?? Enumerable.Empty()) - if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] - {}) is IReadOnlyFilesystem plugin && + if(type.GetConstructor(Type.EmptyTypes)?.Invoke(Array.Empty()) is IReadOnlyFilesystem plugin && !ReadOnlyFilesystems.ContainsKey(plugin.Name.ToLower())) ReadOnlyFilesystems.Add(plugin.Name.ToLower(), plugin); foreach(Type type in pluginRegister.GetAllWritableFloppyImagePlugins() ?? Enumerable.Empty()) - if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] - {}) is IWritableFloppyImage plugin && + if(type.GetConstructor(Type.EmptyTypes)?.Invoke(Array.Empty()) is IWritableFloppyImage plugin && !WritableFloppyImages.ContainsKey(plugin.Name.ToLower())) WritableFloppyImages.Add(plugin.Name.ToLower(), plugin); foreach(Type type in pluginRegister.GetAllWritableImagePlugins() ?? Enumerable.Empty()) - if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] - {}) is IBaseWritableImage plugin && + if(type.GetConstructor(Type.EmptyTypes)?.Invoke(Array.Empty()) is IBaseWritableImage plugin && !WritableImages.ContainsKey(plugin.Name.ToLower())) WritableImages.Add(plugin.Name.ToLower(), plugin); foreach(Type type in pluginRegister.GetAllArchivePlugins() ?? Enumerable.Empty()) - if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] - {}) is IArchive plugin && + if(type.GetConstructor(Type.EmptyTypes)?.Invoke(Array.Empty()) is IArchive plugin && !Archives.ContainsKey(plugin.Name.ToLower())) Archives.Add(plugin.Name.ToLower(), plugin); foreach(Type type in pluginRegister.GetAllByteAddressablePlugins() ?? Enumerable.Empty()) - if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] - {}) is IByteAddressableImage plugin && + if(type.GetConstructor(Type.EmptyTypes)?.Invoke(Array.Empty()) is IByteAddressableImage plugin && !ByteAddressableImages.ContainsKey(plugin.Name.ToLower())) ByteAddressableImages.Add(plugin.Name.ToLower(), plugin); }