Implement IOC for plugin registration.

This commit is contained in:
2018-07-20 22:53:46 +01:00
parent cd489cc40f
commit 991ee84712
27 changed files with 735 additions and 103 deletions

View File

@@ -67,6 +67,7 @@
<e p="MD5Context.cs" t="Include" />
<e p="RIPEMD160Context.cs" t="Include" />
<e p="ReedSolomon.cs" t="Include" />
<e p="Register.cs" t="Include" />
<e p="SHA1Context.cs" t="Include" />
<e p="SHA256Context.cs" t="Include" />
<e p="SHA384Context.cs" t="Include" />
@@ -109,6 +110,7 @@
<e p="IFloppyImage.cs" t="Include" />
<e p="IMediaImage.cs" t="Include" />
<e p="IPartition.cs" t="Include" />
<e p="IPluginRegister.cs" t="Include" />
<e p="IReadOnlyFilesystem.cs" t="Include" />
<e p="IWritableFloppyImage.cs" t="Include" />
<e p="IWritableImage.cs" t="Include" />
@@ -219,6 +221,7 @@
</e>
<e p="DiscImageChef.Core.csproj" t="IncludeRecursive" />
<e p="Filesystems.cs" t="Include" />
<e p="GetPluginBase.cs" t="Include" />
<e p="ImageFormat.cs" t="Include" />
<e p="ImageInfo.cs" t="Include" />
<e p="Logging" t="Include">
@@ -522,6 +525,7 @@
<e p="QCOW2.cs" t="Include" />
<e p="QED.cs" t="Include" />
<e p="RayDIM.cs" t="Include" />
<e p="Register.cs" t="Include" />
<e p="RsIde.cs" t="Include" />
<e p="SaveDskF.cs" t="Include" />
<e p="SuperCardPro.cs" t="Include" />
@@ -659,6 +663,7 @@
<e p="RBF.cs" t="Include" />
<e p="RT11.cs" t="Include" />
<e p="ReFS.cs" t="Include" />
<e p="Register.cs" t="Include" />
<e p="Reiser.cs" t="Include" />
<e p="Reiser4.cs" t="Include" />
<e p="SFS.cs" t="Include" />
@@ -707,6 +712,7 @@
<e p="MacBinary.cs" t="Include" />
<e p="OffsetStream.cs" t="Include" />
<e p="PCExchange.cs" t="Include" />
<e p="Register.cs" t="Include" />
<e p="XZ.cs" t="Include" />
<e p="ZZZNoFilter.cs" t="Include" />
<e p="bin" t="ExcludeRecursive" />
@@ -756,6 +762,7 @@
<e p="PC98.cs" t="Include" />
<e p="Plan9.cs" t="Include" />
<e p="RDB.cs" t="Include" />
<e p="Register.cs" t="Include" />
<e p="RioKarma.cs" t="Include" />
<e p="SGI.cs" t="Include" />
<e p="Sun.cs" t="Include" />

View File

@@ -46,6 +46,7 @@
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="Register.cs" />
<Compile Include="SpamSumContext.cs" />
<Compile Include="Adler32Context.cs" />
<Compile Include="CDChecksums.cs" />

View File

@@ -0,0 +1,95 @@
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : Register.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Core algorithms.
//
// --[ Description ] ----------------------------------------------------------
//
// Registers all plugins in this assembly.
//
// --[ License ] --------------------------------------------------------------
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2018 Natalia Portillo
// ****************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using DiscImageChef.CommonTypes.Interfaces;
namespace DiscImageChef.Checksums
{
public class Register : IPluginRegister
{
public List<Type> GetAllChecksumPlugins()
{
return Assembly.GetExecutingAssembly().GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IChecksum)))
.Where(t => t.IsClass).ToList();
}
public List<Type> GetAllFilesystemPlugins()
{
return null;
}
public List<Type> GetAllFilterPlugins()
{
return null;
}
public List<Type> GetAllFloppyImagePlugins()
{
return null;
}
public List<Type> GetAllMediaImagePlugins()
{
return null;
}
public List<Type> GetAllPartitionPlugins()
{
return null;
}
public List<Type> GetAllReadOnlyFilesystemPlugins()
{
return null;
}
public List<Type> GetAllWritableFloppyImagePlugins()
{
return null;
}
public List<Type> GetAllWritableImagePlugins()
{
return null;
}
}
}

View File

@@ -68,6 +68,7 @@
<Compile Include="Interfaces\IFloppyImage.cs" />
<Compile Include="Interfaces\IMediaImage.cs" />
<Compile Include="Interfaces\IPartition.cs" />
<Compile Include="Interfaces\IPluginRegister.cs" />
<Compile Include="Interfaces\IReadOnlyFilesystem.cs" />
<Compile Include="Interfaces\IWritableFloppyImage.cs" />
<Compile Include="Interfaces\IWritableImage.cs" />

View File

@@ -0,0 +1,100 @@
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : IPluginsRegister.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Interfaces.
//
// --[ Description ] ----------------------------------------------------------
//
// Interface that declares class and methods to call to register plugins.
//
// --[ License ] --------------------------------------------------------------
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2018 Natalia Portillo
// ****************************************************************************/
using System;
using System.Collections.Generic;
namespace DiscImageChef.CommonTypes.Interfaces
{
public interface IPluginRegister
{
/// <summary>
/// Gets all checksum plugins
/// </summary>
/// <returns>List of checksum plugins</returns>
List<Type> GetAllChecksumPlugins();
/// <summary>
/// Gets all filesystem plugins
/// </summary>
/// <returns>List of filesystem plugins</returns>
List<Type> GetAllFilesystemPlugins();
/// <summary>
/// Gets all filter plugins
/// </summary>
/// <returns>List of filter plugins</returns>
List<Type> GetAllFilterPlugins();
/// <summary>
/// Gets all floppy image plugins
/// </summary>
/// <returns>List of floppy image plugins</returns>
List<Type> GetAllFloppyImagePlugins();
/// <summary>
/// Gets all media image plugins
/// </summary>
/// <returns>List of media image plugins</returns>
List<Type> GetAllMediaImagePlugins();
/// <summary>
/// Gets all partition plugins
/// </summary>
/// <returns>List of partition plugins</returns>
List<Type> GetAllPartitionPlugins();
/// <summary>
/// Gets all read-only filesystem plugins
/// </summary>
/// <returns>List of read-only filesystem plugins</returns>
List<Type> GetAllReadOnlyFilesystemPlugins();
/// <summary>
/// Gets all writable floppy image plugins
/// </summary>
/// <returns>List of writable floppy image plugins</returns>
List<Type> GetAllWritableFloppyImagePlugins();
/// <summary>
/// Gets all writable media image plugins
/// </summary>
/// <returns>List of writable media image plugins</returns>
List<Type> GetAllWritableImagePlugins();
}
}

View File

@@ -39,9 +39,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using DiscImageChef.CommonTypes.Interfaces;
using DiscImageChef.Console;
using DiscImageChef.Partitions;
namespace DiscImageChef.CommonTypes
@@ -51,6 +49,18 @@ namespace DiscImageChef.CommonTypes
/// </summary>
public class PluginBase
{
/// <summary>
/// List of checksum plugins
/// </summary>
public readonly List<IChecksum> Checksums;
/// <summary>
/// List of filter plugins
/// </summary>
public readonly SortedDictionary<string, IFilter> Filters;
/// <summary>
/// List of floppy image plugins
/// </summary>
public readonly SortedDictionary<string, IFloppyImage> FloppyImages;
/// <summary>
/// List of all media image plugins
/// </summary>
@@ -68,6 +78,10 @@ namespace DiscImageChef.CommonTypes
/// </summary>
public readonly SortedDictionary<string, IReadOnlyFilesystem> ReadOnlyFilesystems;
/// <summary>
/// List of writable floppy image plugins
/// </summary>
public readonly SortedDictionary<string, IWritableFloppyImage> WritableFloppyImages;
/// <summary>
/// List of writable media image plugins
/// </summary>
public readonly SortedDictionary<string, IWritableImage> WritableImages;
@@ -77,98 +91,62 @@ namespace DiscImageChef.CommonTypes
/// </summary>
public PluginBase()
{
PluginsList = new SortedDictionary<string, IFilesystem>();
ReadOnlyFilesystems = new SortedDictionary<string, IReadOnlyFilesystem>();
PartPluginsList = new SortedDictionary<string, IPartition>();
ImagePluginsList = new SortedDictionary<string, IMediaImage>();
WritableImages = new SortedDictionary<string, IWritableImage>();
// We need to manually load assemblies :(
AppDomain.CurrentDomain.Load("DiscImageChef.DiscImages");
AppDomain.CurrentDomain.Load("DiscImageChef.Filesystems");
AppDomain.CurrentDomain.Load("DiscImageChef.Partitions");
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach(Assembly assembly in assemblies)
{
foreach(Type type in assembly.GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IMediaImage)))
.Where(t => t.IsClass))
try
{
IMediaImage plugin =
(IMediaImage)type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { });
RegisterImagePlugin(plugin);
}
catch(Exception exception) { DicConsole.ErrorWriteLine("Exception {0}", exception); }
foreach(Type type in assembly.GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IPartition)))
.Where(t => t.IsClass))
try
{
IPartition plugin = (IPartition)type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { });
RegisterPartPlugin(plugin);
}
catch(Exception exception) { DicConsole.ErrorWriteLine("Exception {0}", exception); }
foreach(Type type in assembly.GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IFilesystem)))
.Where(t => t.IsClass))
try
{
IFilesystem plugin =
(IFilesystem)type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { });
RegisterPlugin(plugin);
}
catch(Exception exception) { DicConsole.ErrorWriteLine("Exception {0}", exception); }
foreach(Type type in assembly
.GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IReadOnlyFilesystem)))
.Where(t => t.IsClass))
try
{
IReadOnlyFilesystem plugin =
(IReadOnlyFilesystem)type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { });
RegisterReadOnlyFilesystem(plugin);
}
catch(Exception exception) { DicConsole.ErrorWriteLine("Exception {0}", exception); }
foreach(Type type in assembly.GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IWritableImage)))
.Where(t => t.IsClass))
try
{
IWritableImage plugin =
(IWritableImage)type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { });
RegisterWritableMedia(plugin);
}
catch(Exception exception) { DicConsole.ErrorWriteLine("Exception {0}", exception); }
}
PluginsList = new SortedDictionary<string, IFilesystem>();
ReadOnlyFilesystems = new SortedDictionary<string, IReadOnlyFilesystem>();
PartPluginsList = new SortedDictionary<string, IPartition>();
ImagePluginsList = new SortedDictionary<string, IMediaImage>();
WritableImages = new SortedDictionary<string, IWritableImage>();
Checksums = new List<IChecksum>();
Filters = new SortedDictionary<string, IFilter>();
FloppyImages = new SortedDictionary<string, IFloppyImage>();
WritableFloppyImages = new SortedDictionary<string, IWritableFloppyImage>();
}
void RegisterImagePlugin(IMediaImage plugin)
public void AddPlugins(IPluginRegister pluginRegister)
{
if(!ImagePluginsList.ContainsKey(plugin.Name.ToLower()))
ImagePluginsList.Add(plugin.Name.ToLower(), plugin);
}
foreach(Type type in pluginRegister.GetAllChecksumPlugins() ?? Enumerable.Empty<Type>())
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { }) is IChecksum plugin)
Checksums.Add(plugin);
void RegisterPlugin(IFilesystem plugin)
{
if(!PluginsList.ContainsKey(plugin.Name.ToLower())) PluginsList.Add(plugin.Name.ToLower(), plugin);
}
foreach(Type type in pluginRegister.GetAllFilesystemPlugins() ?? Enumerable.Empty<Type>())
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { }) is IFilesystem plugin &&
!PluginsList.ContainsKey(plugin.Name.ToLower()))
PluginsList.Add(plugin.Name.ToLower(), plugin);
void RegisterReadOnlyFilesystem(IReadOnlyFilesystem plugin)
{
if(!ReadOnlyFilesystems.ContainsKey(plugin.Name.ToLower()))
ReadOnlyFilesystems.Add(plugin.Name.ToLower(), plugin);
}
foreach(Type type in pluginRegister.GetAllFilterPlugins() ?? Enumerable.Empty<Type>())
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { }) is IFilter plugin &&
!Filters.ContainsKey(plugin.Name.ToLower()))
Filters.Add(plugin.Name.ToLower(), plugin);
void RegisterWritableMedia(IWritableImage plugin)
{
if(!WritableImages.ContainsKey(plugin.Name.ToLower())) WritableImages.Add(plugin.Name.ToLower(), plugin);
}
foreach(Type type in pluginRegister.GetAllFloppyImagePlugins() ?? Enumerable.Empty<Type>())
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { }) is IFloppyImage plugin &&
!FloppyImages.ContainsKey(plugin.Name.ToLower()))
FloppyImages.Add(plugin.Name.ToLower(), plugin);
void RegisterPartPlugin(IPartition partplugin)
{
if(!PartPluginsList.ContainsKey(partplugin.Name.ToLower()))
PartPluginsList.Add(partplugin.Name.ToLower(), partplugin);
foreach(Type type in pluginRegister.GetAllMediaImagePlugins() ?? Enumerable.Empty<Type>())
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { }) is IMediaImage plugin &&
!ImagePluginsList.ContainsKey(plugin.Name.ToLower()))
ImagePluginsList.Add(plugin.Name.ToLower(), plugin);
foreach(Type type in pluginRegister.GetAllPartitionPlugins() ?? Enumerable.Empty<Type>())
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { }) is IPartition plugin &&
!PartPluginsList.ContainsKey(plugin.Name.ToLower()))
PartPluginsList.Add(plugin.Name.ToLower(), plugin);
foreach(Type type in pluginRegister.GetAllReadOnlyFilesystemPlugins() ?? Enumerable.Empty<Type>())
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { }) is IReadOnlyFilesystem plugin &&
!ReadOnlyFilesystems.ContainsKey(plugin.Name.ToLower()))
ReadOnlyFilesystems.Add(plugin.Name.ToLower(), plugin);
foreach(Type type in pluginRegister.GetAllWritableFloppyImagePlugins() ?? Enumerable.Empty<Type>())
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { }) is IWritableFloppyImage plugin &&
!WritableFloppyImages.ContainsKey(plugin.Name.ToLower()))
WritableFloppyImages.Add(plugin.Name.ToLower(), plugin);
foreach(Type type in pluginRegister.GetAllWritableImagePlugins() ?? Enumerable.Empty<Type>())
if(type.GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { }) is IWritableImage plugin &&
!WritableImages.ContainsKey(plugin.Name.ToLower()))
WritableImages.Add(plugin.Name.ToLower(), plugin);
}
}
}

View File

@@ -46,6 +46,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="GetPluginBase.cs" />
<Compile Include="ImageInfo.cs" />
<Compile Include="Options.cs" />
<Compile Include="ImageFormat.cs" />

View File

@@ -48,7 +48,7 @@ namespace DiscImageChef.Core
/// <param name="partition">Partition</param>
public static void Identify(IMediaImage imagePlugin, out List<string> idPlugins, Partition partition)
{
PluginBase plugins = new PluginBase();
PluginBase plugins = GetPluginBase.Instance;
idPlugins = (from plugin in plugins.PluginsList.Values
where plugin.Identify(imagePlugin, partition)

View File

@@ -0,0 +1,63 @@
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : ImageFormat.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Core algorithms.
//
// --[ Description ] ----------------------------------------------------------
//
// Gets a new instance of all known plugins.
//
// --[ License ] --------------------------------------------------------------
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2018 Natalia Portillo
// ****************************************************************************/
using DiscImageChef.Checksums;
using DiscImageChef.CommonTypes;
using DiscImageChef.CommonTypes.Interfaces;
namespace DiscImageChef.Core
{
public static class GetPluginBase
{
public static PluginBase Instance
{
get
{
PluginBase instance = new PluginBase();
IPluginRegister checksumRegister = new Register();
IPluginRegister imagesRegister = new DiscImages.Register();
IPluginRegister filesystemsRegister = new DiscImageChef.Filesystems.Register();
IPluginRegister filtersRegister = new Filters.Register();
IPluginRegister partitionsRegister = new DiscImageChef.Partitions.Register();
instance.AddPlugins(checksumRegister);
instance.AddPlugins(imagesRegister);
instance.AddPlugins(filesystemsRegister);
instance.AddPlugins(filtersRegister);
instance.AddPlugins(partitionsRegister);
return instance;
}
}
}
}

View File

@@ -49,7 +49,7 @@ namespace DiscImageChef.Core
{
try
{
PluginBase plugins = new PluginBase();
PluginBase plugins = GetPluginBase.Instance;
IMediaImage imageFormat = null;

View File

@@ -51,7 +51,7 @@ namespace DiscImageChef.Core
/// <returns>List of found partitions</returns>
public static List<Partition> GetAll(IMediaImage image)
{
PluginBase plugins = new PluginBase();
PluginBase plugins = GetPluginBase.Instance;
List<Partition> foundPartitions = new List<Partition>();
List<Partition> childPartitions = new List<Partition>();
List<ulong> checkedLocations = new List<ulong>();

View File

@@ -54,7 +54,7 @@ namespace DiscImageChef.Core
public static CICMMetadataType Create(IMediaImage image, string imagePath, Guid filterId, Encoding encoding)
{
CICMMetadataType sidecar = image.CicmMetadata ?? new CICMMetadataType();
PluginBase plugins = new PluginBase();
PluginBase plugins = GetPluginBase.Instance;
FileInfo fi = new FileInfo(imagePath);
FileStream fs = new FileStream(imagePath, FileMode.Open, FileAccess.Read);

View File

@@ -65,6 +65,7 @@
<Compile Include="CDRWin.cs" />
<Compile Include="DiskCopy42.cs" />
<Compile Include="Nero.cs" />
<Compile Include="Register.cs" />
<Compile Include="SuperCardPro.cs" />
<Compile Include="TeleDisk.cs" />
<Compile Include="VHD.cs" />

View File

@@ -0,0 +1,100 @@
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : Register.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Core algorithms.
//
// --[ Description ] ----------------------------------------------------------
//
// Registers all plugins in this assembly.
//
// --[ License ] --------------------------------------------------------------
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2018 Natalia Portillo
// ****************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using DiscImageChef.CommonTypes.Interfaces;
namespace DiscImageChef.DiscImages
{
public class Register : IPluginRegister
{
public List<Type> GetAllChecksumPlugins()
{
return null;
}
public List<Type> GetAllFilesystemPlugins()
{
return null;
}
public List<Type> GetAllFilterPlugins()
{
return null;
}
public List<Type> GetAllFloppyImagePlugins()
{
return Assembly.GetExecutingAssembly().GetTypes()
.Where(t => t.GetInterfaces().Contains(typeof(IFloppyImage))).Where(t => t.IsClass).ToList();
}
public List<Type> GetAllMediaImagePlugins()
{
return Assembly.GetExecutingAssembly().GetTypes()
.Where(t => t.GetInterfaces().Contains(typeof(IMediaImage))).Where(t => t.IsClass).ToList();
}
public List<Type> GetAllPartitionPlugins()
{
return null;
}
public List<Type> GetAllReadOnlyFilesystemPlugins()
{
return null;
}
public List<Type> GetAllWritableFloppyImagePlugins()
{
return Assembly.GetExecutingAssembly().GetTypes()
.Where(t => t.GetInterfaces().Contains(typeof(IWritableFloppyImage))).Where(t => t.IsClass)
.ToList();
}
public List<Type> GetAllWritableImagePlugins()
{
return Assembly.GetExecutingAssembly().GetTypes()
.Where(t => t.GetInterfaces().Contains(typeof(IWritableImage))).Where(t => t.IsClass)
.ToList();
}
}
}

View File

@@ -70,6 +70,7 @@
<Compile Include="PCEngine.cs" />
<Compile Include="ProDOS.cs" />
<Compile Include="ReFS.cs" />
<Compile Include="Register.cs" />
<Compile Include="SolarFS.cs" />
<Compile Include="Symbian.cs" />
<Compile Include="SysV.cs" />

View File

@@ -0,0 +1,97 @@
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : Register.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Core algorithms.
//
// --[ Description ] ----------------------------------------------------------
//
// Registers all plugins in this assembly.
//
// --[ License ] --------------------------------------------------------------
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2018 Natalia Portillo
// ****************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using DiscImageChef.CommonTypes.Interfaces;
namespace DiscImageChef.Filesystems
{
public class Register : IPluginRegister
{
public List<Type> GetAllChecksumPlugins()
{
return null;
}
public List<Type> GetAllFilesystemPlugins()
{
return Assembly.GetExecutingAssembly().GetTypes()
.Where(t => t.GetInterfaces().Contains(typeof(IFilesystem))).Where(t => t.IsClass).ToList();
}
public List<Type> GetAllFilterPlugins()
{
return null;
}
public List<Type> GetAllFloppyImagePlugins()
{
return null;
}
public List<Type> GetAllMediaImagePlugins()
{
return null;
}
public List<Type> GetAllPartitionPlugins()
{
return null;
}
public List<Type> GetAllReadOnlyFilesystemPlugins()
{
return Assembly.GetExecutingAssembly().GetTypes()
.Where(t => t.GetInterfaces().Contains(typeof(IReadOnlyFilesystem))).Where(t => t.IsClass)
.ToList();
}
public List<Type> GetAllWritableFloppyImagePlugins()
{
return null;
}
public List<Type> GetAllWritableImagePlugins()
{
return null;
}
}
}

View File

@@ -46,6 +46,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="OffsetStream.cs" />
<Compile Include="Register.cs" />
<Compile Include="ZZZNoFilter.cs" />
<Compile Include="ForcedSeekStream.cs" />
<Compile Include="GZip.cs" />

View File

@@ -0,0 +1,95 @@
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : Register.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Core algorithms.
//
// --[ Description ] ----------------------------------------------------------
//
// Registers all plugins in this assembly.
//
// --[ License ] --------------------------------------------------------------
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2018 Natalia Portillo
// ****************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using DiscImageChef.CommonTypes.Interfaces;
namespace DiscImageChef.Filters
{
public class Register : IPluginRegister
{
public List<Type> GetAllChecksumPlugins()
{
return null;
}
public List<Type> GetAllFilesystemPlugins()
{
return null;
}
public List<Type> GetAllFilterPlugins()
{
return Assembly.GetExecutingAssembly().GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IFilter)))
.Where(t => t.IsClass).ToList();
}
public List<Type> GetAllFloppyImagePlugins()
{
return null;
}
public List<Type> GetAllMediaImagePlugins()
{
return null;
}
public List<Type> GetAllPartitionPlugins()
{
return null;
}
public List<Type> GetAllReadOnlyFilesystemPlugins()
{
return null;
}
public List<Type> GetAllWritableFloppyImagePlugins()
{
return null;
}
public List<Type> GetAllWritableImagePlugins()
{
return null;
}
}
}

View File

@@ -51,6 +51,7 @@
<Compile Include="MBR.cs" />
<Compile Include="NeXT.cs" />
<Compile Include="RDB.cs" />
<Compile Include="Register.cs" />
<Compile Include="Sun.cs" />
<Compile Include="GPT.cs" />
<Compile Include="RioKarma.cs" />

View File

@@ -0,0 +1,95 @@
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : Register.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Core algorithms.
//
// --[ Description ] ----------------------------------------------------------
//
// Registers all plugins in this assembly.
//
// --[ License ] --------------------------------------------------------------
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2018 Natalia Portillo
// ****************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using DiscImageChef.CommonTypes.Interfaces;
namespace DiscImageChef.Partitions
{
public class Register : IPluginRegister
{
public List<Type> GetAllChecksumPlugins()
{
return null;
}
public List<Type> GetAllFilesystemPlugins()
{
return null;
}
public List<Type> GetAllFilterPlugins()
{
return null;
}
public List<Type> GetAllFloppyImagePlugins()
{
return null;
}
public List<Type> GetAllMediaImagePlugins()
{
return null;
}
public List<Type> GetAllPartitionPlugins()
{
return Assembly.GetExecutingAssembly().GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IPartition)))
.Where(t => t.IsClass).ToList();
}
public List<Type> GetAllReadOnlyFilesystemPlugins()
{
return null;
}
public List<Type> GetAllWritableFloppyImagePlugins()
{
return null;
}
public List<Type> GetAllWritableImagePlugins()
{
return null;
}
}
}

View File

@@ -37,7 +37,6 @@ using DiscImageChef.CommonTypes;
using DiscImageChef.CommonTypes.Interfaces;
using DiscImageChef.Console;
using DiscImageChef.Core;
using DiscImageChef.Filters;
namespace DiscImageChef.Commands
{
@@ -75,7 +74,7 @@ namespace DiscImageChef.Commands
return;
}
PluginBase plugins = new PluginBase();
PluginBase plugins = GetPluginBase.Instance;
bool checkraw = false;

View File

@@ -42,7 +42,6 @@ using DiscImageChef.CommonTypes.Metadata;
using DiscImageChef.CommonTypes.Structs;
using DiscImageChef.Console;
using DiscImageChef.Core;
using DiscImageChef.Filters;
using Schemas;
using Version = DiscImageChef.CommonTypes.Interop.Version;
@@ -146,7 +145,7 @@ namespace DiscImageChef.Commands
return;
}
PluginBase plugins = new PluginBase();
PluginBase plugins = GetPluginBase.Instance;
IMediaImage inputFormat = ImageFormat.Detect(inputFilter);
if(inputFormat == null)

View File

@@ -159,7 +159,7 @@ namespace DiscImageChef.Commands
return;
}
PluginBase plugins = new PluginBase();
PluginBase plugins = GetPluginBase.Instance;
List<IWritableImage> candidates = new List<IWritableImage>();
// Try extension

View File

@@ -39,7 +39,6 @@ using DiscImageChef.CommonTypes.Interfaces;
using DiscImageChef.CommonTypes.Structs;
using DiscImageChef.Console;
using DiscImageChef.Core;
using DiscImageChef.Filters;
namespace DiscImageChef.Commands
{
@@ -83,7 +82,7 @@ namespace DiscImageChef.Commands
return;
}
PluginBase plugins = new PluginBase();
PluginBase plugins = GetPluginBase.Instance;
try
{

View File

@@ -36,7 +36,6 @@ using DiscImageChef.CommonTypes;
using DiscImageChef.CommonTypes.Interfaces;
using DiscImageChef.Console;
using DiscImageChef.Core;
using DiscImageChef.Filters;
using DiscImageChef.Partitions;
namespace DiscImageChef.Commands
@@ -45,7 +44,7 @@ namespace DiscImageChef.Commands
{
internal static void ListFormats(FormatsOptions formatsOptions)
{
PluginBase plugins = new PluginBase();
PluginBase plugins = GetPluginBase.Instance;
FiltersList filtersList = new FiltersList();
DicConsole.WriteLine("Supported filters ({0}):", filtersList.Filters.Count);

View File

@@ -44,7 +44,7 @@ namespace DiscImageChef.Commands
{
internal static void DoList()
{
PluginBase plugins = new PluginBase();
PluginBase plugins = GetPluginBase.Instance;
DicConsole.WriteLine("Read-only filesystems options:");
foreach(KeyValuePair<string, IReadOnlyFilesystem> kvp in plugins.ReadOnlyFilesystems)

View File

@@ -38,7 +38,6 @@ using DiscImageChef.CommonTypes.Interfaces;
using DiscImageChef.CommonTypes.Structs;
using DiscImageChef.Console;
using DiscImageChef.Core;
using DiscImageChef.Filters;
namespace DiscImageChef.Commands
{
@@ -79,7 +78,7 @@ namespace DiscImageChef.Commands
return;
}
PluginBase plugins = new PluginBase();
PluginBase plugins = GetPluginBase.Instance;
try
{