private static void ValidateAndGenerate(Bill bill, ICanvas canvas) { ValidationResult result = Validator.Validate(bill); Bill cleanedBill = result.CleanedBill; if (result.HasErrors) { throw new QRBillValidationException(result); } if (bill.Format.OutputSize == OutputSize.QrCodeOnly) { QRCode qrCode = new QRCode(cleanedBill); qrCode.Draw(canvas, 0, 0); } else { BillLayout layout = new BillLayout(cleanedBill, canvas); layout.Draw(); } }