diff --git a/DocumentService.Client/Models/Results/SwissQrCodeResult.cs b/DocumentService.Client/Models/Results/SwissQrCodeResult.cs index 9656353..a9e0330 100644 --- a/DocumentService.Client/Models/Results/SwissQrCodeResult.cs +++ b/DocumentService.Client/Models/Results/SwissQrCodeResult.cs @@ -13,9 +13,31 @@ namespace DocumentService.Client.Models.Results; /// /// /// PDF validation result. Always populated regardless of whether extraction succeeded. -/// Use +/// Use /// to determine whether the extraction was attempted. /// public record SwissQrCodeResult( SwissQrCodeExtractionResult? QrCode, - PdfValidationResult Validation); + PdfValidationResult Validation) +{ + /// + /// Optional convenience method for code readability. Follows the standard + /// TryXxx pattern (e.g. , + /// ). + /// Use it when you prefer an if/else branch over a null-check on ; + /// it is not required – both approaches are equivalent. + /// + /// + /// When this method returns true, contains the extracted QR Code data. + /// When this method returns false, this value is null and must not be used. + /// + /// + /// true if the PDF was valid and a Swiss QR Code was successfully extracted; + /// false otherwise. + /// + public bool TryExtract(out SwissQrCodeExtractionResult qrCode) + { + qrCode = QrCode ?? null!; + return Validation.IsValid && QrCode is not null; + } +}