Refactor and streamline codebase
- Removed `<Folder>` elements in `DocumentOperator.Domain.csproj` and replaced them with `<Compile Remove>`, `<EmbeddedResource Remove>`, and `<None Remove>` to exclude specific directories. - Removed unused `using DocumentOperator.Domain.Exceptions;` directive. - Simplified `Split` method syntax for delimiter specification. - Updated `return` statements to use concise parameter syntax. - Removed page number validation logic in `DevExpressSwissQrCodeProcessor`. - Replaced default page scanning logic with modern range expression. - Overall, improved code clarity, reduced redundancy, and modernized syntax.
This commit is contained in:
@@ -3,11 +3,9 @@ using DevExpress.Drawing;
|
||||
using DevExpress.Pdf;
|
||||
using DocumentOperator.Application.Common.Interfaces;
|
||||
using DocumentOperator.Domain.Common.Exceptions;
|
||||
using DocumentOperator.Domain.Exceptions;
|
||||
using SkiaSharp;
|
||||
using SkiaSharp.QrCode;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace DocumentOperator.Infrastructure.Services.QrCodeProcessing;
|
||||
|
||||
@@ -85,11 +83,11 @@ public sealed class DevExpressSwissQrCodeProcessor : ISwissQrCodeProcessor
|
||||
// Split raw text into lines (handle both \r\n and \n)
|
||||
// Remove leading/trailing \r and \n from each line
|
||||
var rawLines = qrText
|
||||
.Split(new[] { "\r\n", "\n" }, StringSplitOptions.None)
|
||||
.Split(["\r\n", "\n"], StringSplitOptions.None)
|
||||
.Select(line => line.Trim('\r', '\n'))
|
||||
.ToArray();
|
||||
|
||||
return (success: true, bill: bill, rawLines: rawLines, pageNumber: imageData.pageNumber);
|
||||
return (success: true, bill, rawLines, imageData.pageNumber);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -125,14 +123,10 @@ public sealed class DevExpressSwissQrCodeProcessor : ISwissQrCodeProcessor
|
||||
{
|
||||
// Validate page numbers
|
||||
foreach (int pageNum in pageNumbers)
|
||||
{
|
||||
if (pageNum < 1 || pageNum > totalPages)
|
||||
{
|
||||
throw new ArgumentException(
|
||||
$"Invalid page number {pageNum}. Document has {totalPages} pages.",
|
||||
nameof(pageNumbers));
|
||||
}
|
||||
}
|
||||
return pageNumbers;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user