feat: 初始功能
This commit is contained in:
22
Services/Printing/PrintFileGuards.cs
Normal file
22
Services/Printing/PrintFileGuards.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using CloudPrint.Client.Models;
|
||||
using System.IO;
|
||||
|
||||
namespace CloudPrint.Client.Services.Printing;
|
||||
|
||||
internal static class PrintFileGuards
|
||||
{
|
||||
public static void EnsurePrintableFile(PrintJob job)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(job);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(job.PrinterName))
|
||||
{
|
||||
throw new InvalidOperationException("打印机名称不能为空");
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(job.FilePath) || !File.Exists(job.FilePath))
|
||||
{
|
||||
throw new FileNotFoundException("待打印文件不存在", job.FilePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user