From ef3195498a5e8d5de019f4ec70039ef18eb134d9 Mon Sep 17 00:00:00 2001 From: Claudia Murialdo Date: Tue, 26 Sep 2023 11:12:42 -0300 Subject: [PATCH] Avoid unnecessary casts. --- .../dotnetcore/GxPdfReportsCS/PDFReportItext8.cs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/dotnet/src/dotnetcore/GxPdfReportsCS/PDFReportItext8.cs b/dotnet/src/dotnetcore/GxPdfReportsCS/PDFReportItext8.cs index fa2449944..7e6e5dc37 100644 --- a/dotnet/src/dotnetcore/GxPdfReportsCS/PDFReportItext8.cs +++ b/dotnet/src/dotnetcore/GxPdfReportsCS/PDFReportItext8.cs @@ -974,32 +974,27 @@ private void ProcessHTMLElement(Rectangle htmlRectangle, YPosition currentYPosit return; } - Paragraph p = blockElement as Paragraph; - Table table = blockElement as Table; - List list = blockElement as List; - Link anchor = blockElement as Link; - Image image = blockElement as Image; - if (p != null) + if (blockElement is Paragraph p) { p.SetFixedPosition(this.getPage(), htmlRectangle.GetX(), currentYPosition.CurrentYPosition - blockElementHeight, htmlRectangle.GetWidth()); document.Add(p); } - else if (table != null) + else if (blockElement is Table table) { table.SetFixedPosition(this.getPage(), htmlRectangle.GetX(), currentYPosition.CurrentYPosition - blockElementHeight, htmlRectangle.GetWidth()); document.Add(table); } - else if (list != null) + else if (blockElement is List list) { list.SetFixedPosition(this.getPage(), htmlRectangle.GetX(), currentYPosition.CurrentYPosition - blockElementHeight, htmlRectangle.GetWidth()); document.Add(list); } - else if (anchor != null) + else if (blockElement is Link anchor) { anchor.SetFixedPosition(this.getPage(), htmlRectangle.GetX(), currentYPosition.CurrentYPosition - blockElementHeight, htmlRectangle.GetWidth()); document.Add((IBlockElement)anchor); } - else if (image != null) + else if (blockElement is Image image) { image.SetFixedPosition(this.getPage(), htmlRectangle.GetX(), currentYPosition.CurrentYPosition - blockElementHeight, htmlRectangle.GetWidth()); document.Add(image);