/// <summary> /// Constructs a new compression /// </summary> /// <param name="supportedModes">Operations supported by the compression</param> /// <param name="fileExtensions">Extensions of files where this compression is usually used</param> public Compression(CompressionOperation supportedModes, string[] fileExtensions) { if (supportedModes == CompressionOperation.None) { throw new NotSupportedException("Compression " + this.ToString() + " doesn't support anything."); } this.supportedModes = supportedModes; this.fileExtensions = fileExtensions; }
static void userInterface_OnEvent(CompressionOperation obj) { Compression comp = currentCompression; if (!comp.SupportsOperation(obj)) { throw new NotSupportedException("Compression " + comp.GetType().Name + " doesn't support " + Enum.GetName(typeof(CompressionOperation),obj) + "."); } IUserInterface UI = Program.UI; int inputOffset = UI.InputOffset; int outputOffset = UI.OutputOffset; int inputLength = UI.InputLength; string inputFile = UI.InputFile; string outputFile = UI.OutputFile; switch (obj) { case CompressionOperation.None: throw new NotSupportedException("No action not suported"); case CompressionOperation.Decompress: Decompress(comp, inputFile, outputFile, inputOffset, outputOffset); break; case CompressionOperation.Compress: Compress(comp, inputFile, outputFile, inputOffset, inputLength, outputOffset); break; case CompressionOperation.Scan: Scan(comp, inputFile, outputFile, inputOffset, outputOffset); break; case CompressionOperation.Check: Check(comp, inputFile, inputOffset); break; case CompressionOperation.CompLength: CompLength(comp, inputFile, inputOffset); break; case CompressionOperation.DecompLength: DecompLength(comp, inputFile, inputOffset); break; default: throw new NotSupportedException("Unknown action not suported"); } }
public bool SupportsOperation(CompressionOperation operation) { return (this.supportedModes & operation) == operation; }
public CompressionOperationTests() { mockFileSystem = new MockFileSystem(); target = new CompressionOperation(appConfig.Object, archiveProvider.Object, mockFileSystem); }