28 lines
834 B
C#
28 lines
834 B
C#
using Cryville.Crtr.Extension;
|
|
using Mono.Cecil;
|
|
using System;
|
|
using System.IO;
|
|
|
|
namespace Cryville.Crtr.Extensions {
|
|
internal class ExtensionImporter : ResourceConverter {
|
|
static readonly string[] SUPPORTED_FORMATS = { ".dll" };
|
|
public override string[] GetSupportedFormats() {
|
|
return SUPPORTED_FORMATS;
|
|
}
|
|
|
|
public override void Convert(FileInfo file, ConversionSession ses) {
|
|
try {
|
|
using var stream = file.OpenRead();
|
|
ModuleDefinition.ReadModule(stream, new ReaderParameters(ReadingMode.Immediate));
|
|
}
|
|
catch (BadImageFormatException ex) {
|
|
throw new FormatException("Invalid extension.", ex);
|
|
}
|
|
ses.AddResource(new ExtensionResource(file.Name, file));
|
|
}
|
|
}
|
|
public class ExtensionResource : FileResource {
|
|
public ExtensionResource(string name, FileInfo master) : base(name, master) { }
|
|
}
|
|
}
|