convert ChecksumModule into a Plugin to take advantage of plugin discovery architecture

This commit is contained in:
Michael Becker 2022-10-03 09:37:30 -04:00
parent e998f2cd12
commit cfceb9e32a
No known key found for this signature in database
GPG Key ID: DA394832305DA332
10 changed files with 20 additions and 9 deletions

View File

@ -20,13 +20,14 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using MBS.Framework;
namespace UniversalEditor.Checksum
{
/// <summary>
/// Provides the minimal functionality required to create a checksum calculation module.
/// </summary>
public abstract class ChecksumModule
public abstract class ChecksumPlugin : Plugin
{
/// <summary>
/// The name of this checksum calculation module.

View File

@ -75,7 +75,7 @@ namespace UniversalEditor.Checksum.Modules.Adler32
/// </remarks>
/// <see cref="ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputStream"/>
/// <see cref="ICSharpCode.SharpZipLib.Zip.Compression.Streams.DeflaterOutputStream"/>
public sealed class Adler32ChecksumModule : ChecksumModule
public sealed class Adler32ChecksumModule : ChecksumPlugin
{
public override string Name
{

View File

@ -64,7 +64,7 @@ namespace UniversalEditor.Checksum.Modules.CRC32
/// the information needed to generate CRC's on data a byte at a time for all
/// combinations of CRC register values and incoming bytes.
/// </summary>
public sealed class CRC32ChecksumModule : ChecksumModule
public sealed class CRC32ChecksumModule : ChecksumPlugin
{
const uint CrcSeed = 0xFFFFFFFF;

View File

@ -43,7 +43,7 @@ namespace UniversalEditor.Checksum.Modules.StrangeCRC
/// <summary>
/// Bzip2 checksum algorithm
/// </summary>
public class StrangeCRCChecksumModule : ChecksumModule
public class StrangeCRCChecksumModule : ChecksumPlugin
{
public override string Name { get { return "StrangeCRC"; } }

View File

@ -42,12 +42,18 @@
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="ChecksumModule.cs" />
<Compile Include="ChecksumPlugin.cs" />
<Compile Include="Modules\Adler32\Adler32ChecksumModule.cs" />
<Compile Include="Modules\CRC32\CRC32ChecksumModule.cs" />
<Compile Include="Modules\StrangeCRC\StrangeCRCChecksumModule.cs" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<ProjectReference Include="..\..\..\MBS.Framework\MBS.Framework\MBS.Framework.csproj">
<Project>{00266B21-35C9-4A7F-A6BA-D54D7FDCC25C}</Project>
<Name>MBS.Framework</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -1025,7 +1025,7 @@ namespace ICSharpCode.SharpZipLib.BZip2
int bsBuff;
int bsLive;
ChecksumModule mCrc = new StrangeCRCChecksumModule();
ChecksumPlugin mCrc = new StrangeCRCChecksumModule();
bool[] inUse = new bool[256];
int nInUse;

View File

@ -2052,7 +2052,7 @@ namespace ICSharpCode.SharpZipLib.BZip2
int bytesOut;
int bsBuff;
int bsLive;
ChecksumModule mCrc = new StrangeCRCChecksumModule();
ChecksumPlugin mCrc = new StrangeCRCChecksumModule();
bool[] inUse = new bool[256];
int nInUse;

View File

@ -137,6 +137,10 @@
<Project>{0F7D5BD4-7970-412F-ABD7-0A098BB01ACE}</Project>
<Name>UniversalEditor.Checksum</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\MBS.Framework\MBS.Framework\MBS.Framework.csproj">
<Project>{00266B21-35C9-4A7F-A6BA-D54D7FDCC25C}</Project>
<Name>MBS.Framework</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Modules\Store\" />

View File

@ -73,7 +73,7 @@ namespace UniversalEditor.Plugins.Shadowflare.DataFormats.FileSystem.SMA
}
}
Checksum.ChecksumModule crc = new Checksum.Modules.StrangeCRC.StrangeCRCChecksumModule();
Checksum.ChecksumPlugin crc = new Checksum.Modules.StrangeCRC.StrangeCRCChecksumModule();
protected override void SaveInternal(ObjectModel objectModel)
{

View File

@ -26,7 +26,7 @@ namespace UniversalEditor.Checksum.Modules.GCF
/// <summary>
/// Implements module for calculating checksum used in Valve GCF archives.
/// </summary>
public class GCFChecksumModule : ChecksumModule
public class GCFChecksumModule : ChecksumPlugin
{
public override string Name
{