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:
2026-07-20 09:46:44 +02:00
parent a315fbf890
commit 88984c8887
2 changed files with 8 additions and 10 deletions

View File

@@ -7,8 +7,12 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Common\Results\" /> <Compile Remove="Common\Results\**" />
<Folder Include="Constants\" /> <Compile Remove="Constants\**" />
<EmbeddedResource Remove="Common\Results\**" />
<EmbeddedResource Remove="Constants\**" />
<None Remove="Common\Results\**" />
<None Remove="Constants\**" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -3,11 +3,9 @@ using DevExpress.Drawing;
using DevExpress.Pdf; using DevExpress.Pdf;
using DocumentOperator.Application.Common.Interfaces; using DocumentOperator.Application.Common.Interfaces;
using DocumentOperator.Domain.Common.Exceptions; using DocumentOperator.Domain.Common.Exceptions;
using DocumentOperator.Domain.Exceptions;
using SkiaSharp; using SkiaSharp;
using SkiaSharp.QrCode; using SkiaSharp.QrCode;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Runtime.Versioning;
namespace DocumentOperator.Infrastructure.Services.QrCodeProcessing; 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) // Split raw text into lines (handle both \r\n and \n)
// Remove leading/trailing \r and \n from each line // Remove leading/trailing \r and \n from each line
var rawLines = qrText var rawLines = qrText
.Split(new[] { "\r\n", "\n" }, StringSplitOptions.None) .Split(["\r\n", "\n"], StringSplitOptions.None)
.Select(line => line.Trim('\r', '\n')) .Select(line => line.Trim('\r', '\n'))
.ToArray(); .ToArray();
return (success: true, bill: bill, rawLines: rawLines, pageNumber: imageData.pageNumber); return (success: true, bill, rawLines, imageData.pageNumber);
} }
catch catch
{ {
@@ -125,14 +123,10 @@ public sealed class DevExpressSwissQrCodeProcessor : ISwissQrCodeProcessor
{ {
// Validate page numbers // Validate page numbers
foreach (int pageNum in pageNumbers) foreach (int pageNum in pageNumbers)
{
if (pageNum < 1 || pageNum > totalPages) if (pageNum < 1 || pageNum > totalPages)
{
throw new ArgumentException( throw new ArgumentException(
$"Invalid page number {pageNum}. Document has {totalPages} pages.", $"Invalid page number {pageNum}. Document has {totalPages} pages.",
nameof(pageNumbers)); nameof(pageNumbers));
}
}
return pageNumbers; return pageNumbers;
} }