diff --git a/CHANGELIST.md b/CHANGELIST.md index 281dbed0..700d9606 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -47,6 +47,7 @@ - Make StringEventArgs more complete - Make implicit StringEventArgs bidirectional - Make implicit Result bidirectional +- Rename Result to ResultEventArgs for consistency ### 3.1.9a (2024-05-21) diff --git a/MPF.Check/Program.cs b/MPF.Check/Program.cs index 16822fa4..09e824aa 100644 --- a/MPF.Check/Program.cs +++ b/MPF.Check/Program.cs @@ -39,7 +39,7 @@ namespace MPF.Check } // Make new Progress objects - var resultProgress = new Progress(); + var resultProgress = new Progress(); resultProgress.ProgressChanged += ConsoleLogger.ProgressUpdated; var protectionProgress = new Progress(); protectionProgress.ProgressChanged += ConsoleLogger.ProgressUpdated; diff --git a/MPF.Core/ConsoleLogger.cs b/MPF.Core/ConsoleLogger.cs index e1e852da..965203c0 100644 --- a/MPF.Core/ConsoleLogger.cs +++ b/MPF.Core/ConsoleLogger.cs @@ -9,7 +9,7 @@ namespace MPF.Core /// /// Simple process counter to write to console /// - public static void ProgressUpdated(object? sender, Result value) + public static void ProgressUpdated(object? sender, ResultEventArgs value) { Console.WriteLine(value.Message); } diff --git a/MPF.Core/Data/Result.cs b/MPF.Core/Data/ResultEventArgs.cs similarity index 65% rename from MPF.Core/Data/Result.cs rename to MPF.Core/Data/ResultEventArgs.cs index 8cf2a220..557975ff 100644 --- a/MPF.Core/Data/Result.cs +++ b/MPF.Core/Data/ResultEventArgs.cs @@ -5,7 +5,7 @@ namespace MPF.Core.Data /// /// Generic success/failure result object, with optional message /// - public class Result : EventArgs + public class ResultEventArgs : EventArgs { /// /// Internal representation of success @@ -15,9 +15,9 @@ namespace MPF.Core.Data /// /// Optional message for the result /// - public string Message { get; private set; } + public string Message { get; } - private Result(bool success, string message) + private ResultEventArgs(bool success, string message) { _success = success; Message = message; @@ -26,34 +26,34 @@ namespace MPF.Core.Data /// /// Create a default success result with no message /// - public static Result Success() => new(true, string.Empty); + public static ResultEventArgs Success() => new(true, string.Empty); /// /// Create a success result with a custom message /// /// String to add as a message - public static Result Success(string? message) => new(true, message ?? string.Empty); + public static ResultEventArgs Success(string? message) => new(true, message ?? string.Empty); /// /// Create a default failure result with no message /// /// - public static Result Failure() => new(false, string.Empty); + public static ResultEventArgs Failure() => new(false, string.Empty); /// /// Create a failure result with a custom message /// /// String to add as a message - public static Result Failure(string? message) => new(false, message ?? string.Empty); + public static ResultEventArgs Failure(string? message) => new(false, message ?? string.Empty); /// /// Results can be compared to boolean values based on the success value /// - public static implicit operator bool(Result result) => result._success; + public static implicit operator bool(ResultEventArgs result) => result._success; /// /// Results can be compared to boolean values based on the success value /// - public static implicit operator Result(bool bval) => new(bval, string.Empty); + public static implicit operator ResultEventArgs(bool bval) => new(bval, string.Empty); } } diff --git a/MPF.Core/DumpEnvironment.cs b/MPF.Core/DumpEnvironment.cs index 69feb5e6..6c7e97b4 100644 --- a/MPF.Core/DumpEnvironment.cs +++ b/MPF.Core/DumpEnvironment.cs @@ -233,17 +233,17 @@ namespace MPF.Core /// /// Optional result progress callback #if NET40 - public Result Run(IProgress? progress = null) + public ResultEventArgs Run(IProgress? progress = null) #else - public async Task Run(IProgress? progress = null) + public async Task Run(IProgress? progress = null) #endif { // If we don't have parameters if (ExecutionContext == null) - return Result.Failure("Error! Current configuration is not supported!"); + return ResultEventArgs.Failure("Error! Current configuration is not supported!"); // Check that we have the basics for dumping - Result result = IsValidForDump(); + ResultEventArgs result = IsValidForDump(); if (!result) return result; @@ -256,7 +256,7 @@ namespace MPF.Core } // Execute internal tool - progress?.Report(Result.Success($"Executing {InternalProgram}... {(_options.ToolsInSeparateWindow ? "please wait!" : "see log for output!")}")); + progress?.Report(ResultEventArgs.Success($"Executing {InternalProgram}... {(_options.ToolsInSeparateWindow ? "please wait!" : "see log for output!")}")); var directoryName = Path.GetDirectoryName(OutputPath); if (!string.IsNullOrEmpty(directoryName)) @@ -268,7 +268,7 @@ namespace MPF.Core #else await Task.Run(() => ExecutionContext.ExecuteInternalProgram(_options.ToolsInSeparateWindow)); #endif - progress?.Report(Result.Success($"{InternalProgram} has finished!")); + progress?.Report(ResultEventArgs.Success($"{InternalProgram} has finished!")); // Remove event handler if needed if (!_options.ToolsInSeparateWindow) @@ -288,16 +288,16 @@ namespace MPF.Core /// Optional user prompt to deal with submission information /// A seed SubmissionInfo object that contains user data /// Result instance with the outcome - public async Task VerifyAndSaveDumpOutput( - IProgress? resultProgress = null, + public async Task VerifyAndSaveDumpOutput( + IProgress? resultProgress = null, IProgress? protectionProgress = null, Func? processUserInfo = null, SubmissionInfo? seedInfo = null) { if (ExecutionContext == null && Processor == null) - return Result.Failure("Error! Current configuration is not supported!"); + return ResultEventArgs.Failure("Error! Current configuration is not supported!"); - resultProgress?.Report(Result.Success("Gathering submission information... please wait!")); + resultProgress?.Report(ResultEventArgs.Success("Gathering submission information... please wait!")); // Get the output directory and filename separately var outputDirectory = Path.GetDirectoryName(OutputPath); @@ -307,12 +307,12 @@ namespace MPF.Core (bool foundFiles, List missingFiles) = Processor.FoundAllFiles(outputDirectory, outputFilename, false); if (!foundFiles) { - resultProgress?.Report(Result.Failure($"There were files missing from the output:\n{string.Join("\n", [.. missingFiles])}")); - return Result.Failure("Error! Please check output directory as dump may be incomplete!"); + resultProgress?.Report(ResultEventArgs.Failure($"There were files missing from the output:\n{string.Join("\n", [.. missingFiles])}")); + return ResultEventArgs.Failure("Error! Please check output directory as dump may be incomplete!"); } // Extract the information from the output files - resultProgress?.Report(Result.Success("Extracting output information from output files...")); + resultProgress?.Report(ResultEventArgs.Success("Extracting output information from output files...")); var submissionInfo = await SubmissionInfoTool.ExtractOutputInformation( OutputPath, Drive, @@ -323,128 +323,128 @@ namespace MPF.Core Processor, resultProgress, protectionProgress); - resultProgress?.Report(Result.Success("Extracting information complete!")); + resultProgress?.Report(ResultEventArgs.Success("Extracting information complete!")); // Inject seed submission info data, if necessary if (seedInfo != null) { - resultProgress?.Report(Result.Success("Injecting user-supplied information...")); + resultProgress?.Report(ResultEventArgs.Success("Injecting user-supplied information...")); Builder.InjectSubmissionInformation(submissionInfo, seedInfo); - resultProgress?.Report(Result.Success("Information injection complete!")); + resultProgress?.Report(ResultEventArgs.Success("Information injection complete!")); } // Eject the disc automatically if configured to if (_options.EjectAfterDump == true) { - resultProgress?.Report(Result.Success($"Ejecting disc in drive {Drive?.Name}")); + resultProgress?.Report(ResultEventArgs.Success($"Ejecting disc in drive {Drive?.Name}")); await EjectDisc(); } // Reset the drive automatically if configured to if (InternalProgram == InternalProgram.DiscImageCreator && _options.DICResetDriveAfterDump) { - resultProgress?.Report(Result.Success($"Resetting drive {Drive?.Name}")); + resultProgress?.Report(ResultEventArgs.Success($"Resetting drive {Drive?.Name}")); await ResetDrive(); } // Get user-modifiable information if confugured to if (_options.PromptForDiscInformation && processUserInfo != null) { - resultProgress?.Report(Result.Success("Waiting for additional disc information...")); + resultProgress?.Report(ResultEventArgs.Success("Waiting for additional disc information...")); bool? filledInfo; (filledInfo, submissionInfo) = processUserInfo(submissionInfo); if (filledInfo == true) - resultProgress?.Report(Result.Success("Additional disc information added!")); + resultProgress?.Report(ResultEventArgs.Success("Additional disc information added!")); else - resultProgress?.Report(Result.Success("Disc information skipped!")); + resultProgress?.Report(ResultEventArgs.Success("Disc information skipped!")); } // Process special fields for site codes - resultProgress?.Report(Result.Success("Processing site codes...")); + resultProgress?.Report(ResultEventArgs.Success("Processing site codes...")); Formatter.ProcessSpecialFields(submissionInfo); - resultProgress?.Report(Result.Success("Processing complete!")); + resultProgress?.Report(ResultEventArgs.Success("Processing complete!")); // Format the information for the text output - resultProgress?.Report(Result.Success("Formatting information...")); + resultProgress?.Report(ResultEventArgs.Success("Formatting information...")); (var formattedValues, var formatResult) = Formatter.FormatOutputData(submissionInfo, _options.EnableRedumpCompatibility); if (formattedValues == null) - resultProgress?.Report(Result.Failure(formatResult)); + resultProgress?.Report(ResultEventArgs.Failure(formatResult)); else - resultProgress?.Report(Result.Success(formatResult)); + resultProgress?.Report(ResultEventArgs.Success(formatResult)); // Get the filename suffix for auto-generated files var filenameSuffix = _options.AddFilenameSuffix ? Path.GetFileNameWithoutExtension(outputFilename) : null; // Write the text output - resultProgress?.Report(Result.Success("Writing information to !submissionInfo.txt...")); + resultProgress?.Report(ResultEventArgs.Success("Writing information to !submissionInfo.txt...")); (bool txtSuccess, string txtResult) = InfoTool.WriteOutputData(outputDirectory, filenameSuffix, formattedValues); if (txtSuccess) - resultProgress?.Report(Result.Success(txtResult)); + resultProgress?.Report(ResultEventArgs.Success(txtResult)); else - resultProgress?.Report(Result.Failure(txtResult)); + resultProgress?.Report(ResultEventArgs.Failure(txtResult)); // Write the copy protection output if (submissionInfo?.CopyProtection?.FullProtections != null && submissionInfo.CopyProtection.FullProtections.Any()) { if (_options.ScanForProtection && _options.OutputSeparateProtectionFile) { - resultProgress?.Report(Result.Success("Writing protection to !protectionInfo.txt...")); + resultProgress?.Report(ResultEventArgs.Success("Writing protection to !protectionInfo.txt...")); bool scanSuccess = InfoTool.WriteProtectionData(outputDirectory, filenameSuffix, submissionInfo, _options.HideDriveLetters); if (scanSuccess) - resultProgress?.Report(Result.Success("Writing complete!")); + resultProgress?.Report(ResultEventArgs.Success("Writing complete!")); else - resultProgress?.Report(Result.Failure("Writing could not complete!")); + resultProgress?.Report(ResultEventArgs.Failure("Writing could not complete!")); } } // Write the JSON output, if required if (_options.OutputSubmissionJSON) { - resultProgress?.Report(Result.Success($"Writing information to !submissionInfo.json{(_options.IncludeArtifacts ? ".gz" : string.Empty)}...")); + resultProgress?.Report(ResultEventArgs.Success($"Writing information to !submissionInfo.json{(_options.IncludeArtifacts ? ".gz" : string.Empty)}...")); bool jsonSuccess = InfoTool.WriteOutputData(outputDirectory, filenameSuffix, submissionInfo, _options.IncludeArtifacts); if (jsonSuccess) - resultProgress?.Report(Result.Success("Writing complete!")); + resultProgress?.Report(ResultEventArgs.Success("Writing complete!")); else - resultProgress?.Report(Result.Failure("Writing could not complete!")); + resultProgress?.Report(ResultEventArgs.Failure("Writing could not complete!")); } // Compress the logs, if required if (_options.CompressLogFiles) { - resultProgress?.Report(Result.Success("Compressing log files...")); + resultProgress?.Report(ResultEventArgs.Success("Compressing log files...")); (bool compressSuccess, string compressResult) = InfoTool.CompressLogFiles(outputDirectory, filenameSuffix, outputFilename, Processor); if (compressSuccess) - resultProgress?.Report(Result.Success(compressResult)); + resultProgress?.Report(ResultEventArgs.Success(compressResult)); else - resultProgress?.Report(Result.Failure(compressResult)); + resultProgress?.Report(ResultEventArgs.Failure(compressResult)); } // Delete unnecessary files, if required if (_options.DeleteUnnecessaryFiles) { - resultProgress?.Report(Result.Success("Deleting unnecessary files...")); + resultProgress?.Report(ResultEventArgs.Success("Deleting unnecessary files...")); (bool deleteSuccess, string deleteResult) = InfoTool.DeleteUnnecessaryFiles(outputDirectory, outputFilename, Processor); if (deleteSuccess) - resultProgress?.Report(Result.Success(deleteResult)); + resultProgress?.Report(ResultEventArgs.Success(deleteResult)); else - resultProgress?.Report(Result.Failure(deleteResult)); + resultProgress?.Report(ResultEventArgs.Failure(deleteResult)); } // Create PS3 IRD, if required if (_options.CreateIRDAfterDumping && System == RedumpSystem.SonyPlayStation3 && Type == MediaType.BluRay) { - resultProgress?.Report(Result.Success("Creating IRD... please wait!")); + resultProgress?.Report(ResultEventArgs.Success("Creating IRD... please wait!")); (bool deleteSuccess, string deleteResult) = await InfoTool.WriteIRD(OutputPath, submissionInfo?.Extras?.DiscKey, submissionInfo?.Extras?.DiscID, submissionInfo?.Extras?.PIC, submissionInfo?.SizeAndChecksums?.Layerbreak, submissionInfo?.SizeAndChecksums?.CRC32); if (deleteSuccess) - resultProgress?.Report(Result.Success(deleteResult)); + resultProgress?.Report(ResultEventArgs.Success(deleteResult)); else - resultProgress?.Report(Result.Failure(deleteResult)); + resultProgress?.Report(ResultEventArgs.Failure(deleteResult)); } - resultProgress?.Report(Result.Success("Submission information process complete!")); - return Result.Success(); + resultProgress?.Report(ResultEventArgs.Success("Submission information process complete!")); + return ResultEventArgs.Success(); } /// @@ -512,27 +512,27 @@ namespace MPF.Core /// Validate the current environment is ready for a dump /// /// Result instance with the outcome - private Result IsValidForDump() + private ResultEventArgs IsValidForDump() { // Validate that everything is good if (ExecutionContext == null || !ParametersValid()) - return Result.Failure("Error! Current configuration is not supported!"); + return ResultEventArgs.Failure("Error! Current configuration is not supported!"); // Fix the output paths, just in case OutputPath = InfoTool.NormalizeOutputPaths(OutputPath, false); // Validate that the output path isn't on the dumping drive if (Drive?.Name != null && OutputPath.StartsWith(Drive.Name)) - return Result.Failure("Error! Cannot output to same drive that is being dumped!"); + return ResultEventArgs.Failure("Error! Cannot output to same drive that is being dumped!"); // Validate that the required program exists if (!File.Exists(ExecutionContext.ExecutablePath)) - return Result.Failure($"Error! {ExecutionContext.ExecutablePath} does not exist!"); + return ResultEventArgs.Failure($"Error! {ExecutionContext.ExecutablePath} does not exist!"); // Validate that the dumping drive doesn't contain the executable string fullExecutablePath = Path.GetFullPath(ExecutionContext.ExecutablePath!); if (Drive?.Name != null && fullExecutablePath.StartsWith(Drive.Name)) - return Result.Failure("Error! Cannot dump same drive that executable resides on!"); + return ResultEventArgs.Failure("Error! Cannot dump same drive that executable resides on!"); // Validate that the current configuration is supported return Tools.GetSupportStatus(System, Type); diff --git a/MPF.Core/SubmissionInfoTool.cs b/MPF.Core/SubmissionInfoTool.cs index 8d330b4e..66c19e0c 100644 --- a/MPF.Core/SubmissionInfoTool.cs +++ b/MPF.Core/SubmissionInfoTool.cs @@ -49,7 +49,7 @@ namespace MPF.Core Data.Options options, BaseExecutionContext? executionContext, BaseProcessor? processor, - IProgress? resultProgress = null, + IProgress? resultProgress = null, IProgress? protectionProgress = null) { // Ensure the current disc combination should exist @@ -64,8 +64,8 @@ namespace MPF.Core (bool foundFiles, List missingFiles) = processor.FoundAllFiles(outputDirectory, outputFilename, false); if (!foundFiles) { - resultProgress?.Report(Result.Failure($"There were files missing from the output:\n{string.Join("\n", [.. missingFiles])}")); - resultProgress?.Report(Result.Failure($"This may indicate an issue with the hardware or media, including unsupported devices.\nPlease see dumping program documentation for more details.")); + resultProgress?.Report(ResultEventArgs.Failure($"There were files missing from the output:\n{string.Join("\n", [.. missingFiles])}")); + resultProgress?.Report(ResultEventArgs.Failure($"This may indicate an issue with the hardware or media, including unsupported devices.\nPlease see dumping program documentation for more details.")); return null; } @@ -113,12 +113,12 @@ namespace MPF.Core // Run copy protection, if possible or necessary if (SupportsCopyProtectionScans(system)) { - resultProgress?.Report(Result.Success("Running copy protection scan... this might take a while!")); + resultProgress?.Report(ResultEventArgs.Success("Running copy protection scan... this might take a while!")); var (protectionString, fullProtections) = await InfoTool.GetCopyProtection(drive, options, protectionProgress); info.CopyProtection!.Protection += protectionString; info.CopyProtection.FullProtections = fullProtections as Dictionary?> ?? []; - resultProgress?.Report(Result.Success("Copy protection scan complete!")); + resultProgress?.Report(ResultEventArgs.Success("Copy protection scan complete!")); } // Set fields that may have automatic filling otherwise @@ -144,9 +144,9 @@ namespace MPF.Core /// Existing SubmissionInfo object to fill /// Optional result progress callback #if NET40 - public static bool FillFromRedump(Data.Options options, SubmissionInfo info, IProgress? resultProgress = null) + public static bool FillFromRedump(Data.Options options, SubmissionInfo info, IProgress? resultProgress = null) #else - public async static Task FillFromRedump(Data.Options options, SubmissionInfo info, IProgress? resultProgress = null) + public async static Task FillFromRedump(Data.Options options, SubmissionInfo info, IProgress? resultProgress = null) #endif { // If no username is provided @@ -168,7 +168,7 @@ namespace MPF.Core #endif if (loggedIn == null) { - resultProgress?.Report(Result.Failure("There was an unknown error connecting to Redump")); + resultProgress?.Report(ResultEventArgs.Failure("There was an unknown error connecting to Redump")); return false; } else if (loggedIn == false) @@ -182,7 +182,7 @@ namespace MPF.Core List? fullyMatchedIDs = null; // Loop through all of the hashdata to find matching IDs - resultProgress?.Report(Result.Success("Finding disc matches on Redump...")); + resultProgress?.Report(ResultEventArgs.Success("Finding disc matches on Redump...")); var splitData = info.TracksAndWriteOffsets?.ClrMameProData?.TrimEnd('\n')?.Split('\n'); int trackCount = splitData?.Length ?? 0; foreach (string hashData in splitData ?? []) @@ -191,7 +191,7 @@ namespace MPF.Core if (string.IsNullOrEmpty(hashData)) { trackCount--; - resultProgress?.Report(Result.Success("Blank line found, skipping!")); + resultProgress?.Report(ResultEventArgs.Success("Blank line found, skipping!")); continue; } @@ -206,14 +206,14 @@ namespace MPF.Core || hashData.Contains("(Track AA.2).bin")) { trackCount--; - resultProgress?.Report(Result.Success("Extra track found, skipping!")); + resultProgress?.Report(ResultEventArgs.Success("Extra track found, skipping!")); continue; } // Get the SHA-1 hash if (!InfoTool.GetISOHashValues(hashData, out _, out _, out _, out string? sha1)) { - resultProgress?.Report(Result.Failure($"Line could not be parsed: {hashData}")); + resultProgress?.Report(ResultEventArgs.Failure($"Line could not be parsed: {hashData}")); continue; } @@ -225,9 +225,9 @@ namespace MPF.Core (bool singleFound, var foundIds, string? result) = await Validator.ValidateSingleTrack(wc, info, sha1); #endif if (singleFound) - resultProgress?.Report(Result.Success(result)); + resultProgress?.Report(ResultEventArgs.Success(result)); else - resultProgress?.Report(Result.Failure(result)); + resultProgress?.Report(ResultEventArgs.Failure(result)); // Ensure that all tracks are found allFound &= singleFound; @@ -258,9 +258,9 @@ namespace MPF.Core (bool singleFound, var foundIds, string? result) = await Validator.ValidateUniversalHash(wc, info); #endif if (singleFound) - resultProgress?.Report(Result.Success(result)); + resultProgress?.Report(ResultEventArgs.Success(result)); else - resultProgress?.Report(Result.Failure(result)); + resultProgress?.Report(ResultEventArgs.Failure(result)); // Ensure that the hash is found allFound = singleFound; @@ -280,7 +280,7 @@ namespace MPF.Core // Make sure we only have unique IDs info.PartiallyMatchedIDs = [.. info.PartiallyMatchedIDs.Distinct().OrderBy(id => id)]; - resultProgress?.Report(Result.Success("Match finding complete! " + (fullyMatchedIDs != null && fullyMatchedIDs.Count > 0 + resultProgress?.Report(ResultEventArgs.Success("Match finding complete! " + (fullyMatchedIDs != null && fullyMatchedIDs.Count > 0 ? "Fully Matched IDs: " + string.Join(",", fullyMatchedIDs.Select(i => i.ToString()).ToArray()) : "No matches found"))); @@ -303,7 +303,7 @@ namespace MPF.Core continue; // Fill in the fields from the existing ID - resultProgress?.Report(Result.Success($"Filling fields from existing ID {fullyMatchedIDs[i]}...")); + resultProgress?.Report(ResultEventArgs.Success($"Filling fields from existing ID {fullyMatchedIDs[i]}...")); #if NET40 var fillTask = Task.Factory.StartNew(() => Builder.FillFromId(wc, info, fullyMatchedIDs[i], options.PullAllInformation)); fillTask.Wait(); @@ -311,7 +311,7 @@ namespace MPF.Core #else _ = await Builder.FillFromId(wc, info, fullyMatchedIDs[i], options.PullAllInformation); #endif - resultProgress?.Report(Result.Success("Information filling complete!")); + resultProgress?.Report(ResultEventArgs.Success("Information filling complete!")); // Set the fully matched ID to the current info.FullyMatchedID = fullyMatchedIDs[i]; @@ -587,7 +587,7 @@ namespace MPF.Core RedumpSystem? system, Drive? drive, bool addPlaceholders, - IProgress? resultProgress = null) + IProgress? resultProgress = null) { // Extract info based specifically on RedumpSystem switch (system) @@ -800,9 +800,9 @@ namespace MPF.Core if (drive != null && info.CopyProtection!.AntiModchip == YesNo.NULL) { - resultProgress?.Report(Result.Success("Checking for anti-modchip strings... this might take a while!")); + resultProgress?.Report(ResultEventArgs.Success("Checking for anti-modchip strings... this might take a while!")); info.CopyProtection.AntiModchip = await InfoTool.GetAntiModchipDetected(drive) ? YesNo.Yes : YesNo.No; - resultProgress?.Report(Result.Success("Anti-modchip string scan complete!")); + resultProgress?.Report(ResultEventArgs.Success("Anti-modchip string scan complete!")); } break; diff --git a/MPF.Core/UI/ViewModels/CheckDumpViewModel.cs b/MPF.Core/UI/ViewModels/CheckDumpViewModel.cs index 89b68f16..d0a09f27 100644 --- a/MPF.Core/UI/ViewModels/CheckDumpViewModel.cs +++ b/MPF.Core/UI/ViewModels/CheckDumpViewModel.cs @@ -463,7 +463,7 @@ namespace MPF.Core.UI.ViewModels var env = new DumpEnvironment(Options, Path.GetFullPath(this.InputPath.Trim('"')), null, this.CurrentSystem, this.CurrentMediaType, this.CurrentProgram, parameters: null); // Make new Progress objects - var resultProgress = new Progress(); + var resultProgress = new Progress(); resultProgress.ProgressChanged += ConsoleLogger.ProgressUpdated; var protectionProgress = new Progress(); protectionProgress.ProgressChanged += ConsoleLogger.ProgressUpdated; diff --git a/MPF.Core/UI/ViewModels/MainViewModel.cs b/MPF.Core/UI/ViewModels/MainViewModel.cs index b4d1aa4e..85e20ff2 100644 --- a/MPF.Core/UI/ViewModels/MainViewModel.cs +++ b/MPF.Core/UI/ViewModels/MainViewModel.cs @@ -1328,7 +1328,7 @@ namespace MPF.Core.UI.ViewModels _environment = DetermineEnvironment(); // Get the status to write out - Result result = Tools.GetSupportStatus(_environment.System, _environment.Type); + ResultEventArgs result = Tools.GetSupportStatus(_environment.System, _environment.Type); if (this.CurrentProgram == InternalProgram.NONE || _environment.ExecutionContext == null) this.Status = "No dumping program found"; else @@ -1698,7 +1698,7 @@ namespace MPF.Core.UI.ViewModels LogLn("Program outputs may be slow to populate in the log window"); // Get progress indicators - var resultProgress = new Progress(); + var resultProgress = new Progress(); resultProgress.ProgressChanged += ProgressUpdated; var protectionProgress = new Progress(); protectionProgress.ProgressChanged += ProgressUpdated; @@ -1706,9 +1706,9 @@ namespace MPF.Core.UI.ViewModels // Run the program with the parameters #if NET40 - Result result = _environment.Run(resultProgress); + ResultEventArgs result = _environment.Run(resultProgress); #else - Result result = await _environment.Run(resultProgress); + ResultEventArgs result = await _environment.Run(resultProgress); #endif // If we didn't execute a dumping command we cannot get submission output @@ -1927,7 +1927,7 @@ namespace MPF.Core.UI.ViewModels /// /// Handler for Result ProgressChanged event /// - private void ProgressUpdated(object? sender, Result value) + private void ProgressUpdated(object? sender, ResultEventArgs value) { var message = value?.Message; diff --git a/MPF.Core/Utilities/Tools.cs b/MPF.Core/Utilities/Tools.cs index 6cc0aad6..fa4da512 100644 --- a/MPF.Core/Utilities/Tools.cs +++ b/MPF.Core/Utilities/Tools.cs @@ -108,11 +108,11 @@ namespace MPF.Core.Utilities /// /// Verify that, given a system and a media type, they are correct /// - public static Result GetSupportStatus(RedumpSystem? system, MediaType? type) + public static ResultEventArgs GetSupportStatus(RedumpSystem? system, MediaType? type) { // No system chosen, update status if (system == null) - return Result.Failure("Please select a valid system"); + return ResultEventArgs.Failure("Please select a valid system"); // If we're on an unsupported type, update the status accordingly return type switch @@ -126,21 +126,21 @@ namespace MPF.Core.Utilities or MediaType.CompactFlash or MediaType.SDCard or MediaType.FlashDrive - or MediaType.HDDVD => Result.Success($"{type.LongName()} ready to dump"), + or MediaType.HDDVD => ResultEventArgs.Success($"{type.LongName()} ready to dump"), // Partially supported types MediaType.GDROM or MediaType.NintendoGameCubeGameDisc - or MediaType.NintendoWiiOpticalDisc => Result.Success($"{type.LongName()} partially supported for dumping"), + or MediaType.NintendoWiiOpticalDisc => ResultEventArgs.Success($"{type.LongName()} partially supported for dumping"), // Special case for other supported tools - MediaType.UMD => Result.Failure($"{type.LongName()} supported for submission info parsing"), + MediaType.UMD => ResultEventArgs.Failure($"{type.LongName()} supported for submission info parsing"), // Specifically unknown type - MediaType.NONE => Result.Failure($"Please select a valid media type"), + MediaType.NONE => ResultEventArgs.Failure($"Please select a valid media type"), // Undumpable but recognized types - _ => Result.Failure($"{type.LongName()} media are not supported for dumping"), + _ => ResultEventArgs.Failure($"{type.LongName()} media are not supported for dumping"), }; } diff --git a/MPF.Test/Core/Data/ResultTests.cs b/MPF.Test/Core/Data/ResultTests.cs index d96ecdc5..642c3319 100644 --- a/MPF.Test/Core/Data/ResultTests.cs +++ b/MPF.Test/Core/Data/ResultTests.cs @@ -8,7 +8,7 @@ namespace MPF.Test.Core.Data [Fact] public void EmptySuccessTest() { - var actual = Result.Success(); + var actual = ResultEventArgs.Success(); Assert.True(actual); Assert.Empty(actual.Message); } @@ -17,7 +17,7 @@ namespace MPF.Test.Core.Data public void CustomMessageSuccessTest() { string message = "Success!"; - var actual = Result.Success(message); + var actual = ResultEventArgs.Success(message); Assert.True(actual); Assert.Equal(message, actual.Message); } @@ -25,7 +25,7 @@ namespace MPF.Test.Core.Data [Fact] public void EmptyFailureTest() { - var actual = Result.Failure(); + var actual = ResultEventArgs.Failure(); Assert.False(actual); Assert.Empty(actual.Message); } @@ -34,7 +34,7 @@ namespace MPF.Test.Core.Data public void CustomMessageFailureTest() { string message = "Failure!"; - var actual = Result.Failure(message); + var actual = ResultEventArgs.Failure(message); Assert.False(actual); Assert.Equal(message, actual.Message); }