Class OdfExternalValidator
- Namespace
- OdfKit.Compliance
- Assembly
- OdfKit.dll
Provides the OdfExternalValidator API. 提供呼叫外部 ODF 驗證器的輔助方法。
public static class OdfExternalValidator
- Inheritance
-
OdfExternalValidator
- Inherited Members
Fields
OdfValidatorJarEnvironmentVariable
取得 ODF Validator JAR 路徑的環境變數名稱。
public const string OdfValidatorJarEnvironmentVariable = "ODFKIT_ODFVALIDATOR_JAR"
Field Value
Methods
ValidateWithCommand(string, string)
Short overload of ValidateWithCommand that accepts commandPath and filePath; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 commandPath 與 filePath;其餘可選參數使用預設值並轉呼叫最長 ValidateWithCommand 多載。
public static OdfExternalValidatorResult ValidateWithCommand(string commandPath, string filePath)
Parameters
Returns
ValidateWithCommand(string, string, int)
Validates with command. 執行可選外部驗證命令並以結束碼判定 valid / invalid。
public static OdfExternalValidatorResult ValidateWithCommand(string commandPath, string filePath, int timeoutMilliseconds)
Parameters
Returns
- OdfExternalValidatorResult
外部驗證器執行結果
Remarks
Prefer ValidateWithCommandAsync(string, string, int, CancellationToken) in server environments to avoid blocking request threads. 在 ASP.NET Core 等伺服器環境中,請優先使用 ValidateWithCommandAsync(string, string, int, CancellationToken) 以避免阻塞要求執行緒。
ValidateWithCommandAsync(string, string)
Short overload of ValidateWithCommandAsync that accepts commandPath and filePath; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 commandPath 與 filePath;其餘可選參數使用預設值並轉呼叫最長 ValidateWithCommandAsync 多載。
public static Task<OdfExternalValidatorResult> ValidateWithCommandAsync(string commandPath, string filePath)
Parameters
Returns
ValidateWithCommandAsync(string, string, int)
Short overload of ValidateWithCommandAsync that accepts commandPath, filePath, and timeoutMilliseconds; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 commandPath、filePath 與 timeoutMilliseconds;其餘可選參數使用預設值並轉呼叫最長 ValidateWithCommandAsync 多載。
public static Task<OdfExternalValidatorResult> ValidateWithCommandAsync(string commandPath, string filePath, int timeoutMilliseconds)
Parameters
Returns
ValidateWithCommandAsync(string, string, int, CancellationToken)
Validates with command async. 非同步執行可選外部驗證命令並以結束碼判定 valid / invalid。
public static Task<OdfExternalValidatorResult> ValidateWithCommandAsync(string commandPath, string filePath, int timeoutMilliseconds, CancellationToken cancellationToken)
Parameters
commandPathstring外部命令路徑
filePathstring要驗證的 ODF 文件路徑
timeoutMillisecondsint外部程序逾時毫秒數
cancellationTokenCancellationToken取消語彙基元
Returns
- Task<OdfExternalValidatorResult>
代表非同步驗證作業的工作,其結果為外部驗證器執行結果
Remarks
若 cancellationToken 已請求取消,作業會立即以 OperationCanceledException 結束;
否則會在外部子程序等待與 stdout/stderr 讀取期間協作檢查取消語彙。
ValidateWithOdfValidator(string)
Short overload of ValidateWithOdfValidator that accepts filePath; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 filePath;其餘可選參數使用預設值並轉呼叫最長 ValidateWithOdfValidator 多載。
public static OdfExternalValidatorResult ValidateWithOdfValidator(string filePath)
Parameters
filePathstring
Returns
ValidateWithOdfValidator(string, string?)
Short overload of ValidateWithOdfValidator that accepts filePath and jarPath; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 filePath 與 jarPath;其餘可選參數使用預設值並轉呼叫最長 ValidateWithOdfValidator 多載。
public static OdfExternalValidatorResult ValidateWithOdfValidator(string filePath, string? jarPath)
Parameters
Returns
ValidateWithOdfValidator(string, string?, string?)
Short overload of ValidateWithOdfValidator that accepts filePath, jarPath, and javaPath; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 filePath、jarPath 與 javaPath;其餘可選參數使用預設值並轉呼叫最長 ValidateWithOdfValidator 多載。
public static OdfExternalValidatorResult ValidateWithOdfValidator(string filePath, string? jarPath, string? javaPath)
Parameters
Returns
ValidateWithOdfValidator(string, string?, string?, int)
Validates with odf validator. 使用 ODF Toolkit 的 ODF Validator JAR 驗證指定文件。
public static OdfExternalValidatorResult ValidateWithOdfValidator(string filePath, string? jarPath, string? javaPath, int timeoutMilliseconds)
Parameters
filePathstring要驗證的 ODF 文件路徑
jarPathstringODF Validator JAR 路徑。若未提供,會讀取
ODFKIT_ODFVALIDATOR_JARjavaPathstringJava 執行檔路徑。預設使用
javatimeoutMillisecondsint外部程序逾時毫秒數
Returns
- OdfExternalValidatorResult
外部驗證器執行結果
Remarks
Prefer ValidateWithOdfValidatorAsync(string, string?, string?, int, CancellationToken) in server environments to avoid blocking request threads. 在 ASP.NET Core 等伺服器環境中,請優先使用 ValidateWithOdfValidatorAsync(string, string?, string?, int, CancellationToken) 以避免阻塞要求執行緒。
Exceptions
- ArgumentException
當文件路徑或 JAR 路徑未提供時擲出
- FileNotFoundException
當文件或 JAR 不存在時擲出
- TimeoutException
當外部程序逾時時擲出
ValidateWithOdfValidatorAsync(string)
Short overload of ValidateWithOdfValidatorAsync that accepts filePath; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 filePath;其餘可選參數使用預設值並轉呼叫最長 ValidateWithOdfValidatorAsync 多載。
public static Task<OdfExternalValidatorResult> ValidateWithOdfValidatorAsync(string filePath)
Parameters
filePathstring
Returns
ValidateWithOdfValidatorAsync(string, string?)
Short overload of ValidateWithOdfValidatorAsync that accepts filePath and jarPath; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 filePath 與 jarPath;其餘可選參數使用預設值並轉呼叫最長 ValidateWithOdfValidatorAsync 多載。
public static Task<OdfExternalValidatorResult> ValidateWithOdfValidatorAsync(string filePath, string? jarPath)
Parameters
Returns
ValidateWithOdfValidatorAsync(string, string?, string?)
Short overload of ValidateWithOdfValidatorAsync that accepts filePath, jarPath, and javaPath; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 filePath、jarPath 與 javaPath;其餘可選參數使用預設值並轉呼叫最長 ValidateWithOdfValidatorAsync 多載。
public static Task<OdfExternalValidatorResult> ValidateWithOdfValidatorAsync(string filePath, string? jarPath, string? javaPath)
Parameters
Returns
ValidateWithOdfValidatorAsync(string, string?, string?, int)
Short overload of ValidateWithOdfValidatorAsync that accepts filePath, jarPath, javaPath, and timeoutMilliseconds; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 filePath、jarPath、javaPath 與 timeoutMilliseconds;其餘可選參數使用預設值並轉呼叫最長 ValidateWithOdfValidatorAsync 多載。
public static Task<OdfExternalValidatorResult> ValidateWithOdfValidatorAsync(string filePath, string? jarPath, string? javaPath, int timeoutMilliseconds)
Parameters
Returns
ValidateWithOdfValidatorAsync(string, string?, string?, int, CancellationToken)
Validates with odf validator async. 非同步使用 ODF Toolkit 的 ODF Validator JAR 驗證指定文件。
public static Task<OdfExternalValidatorResult> ValidateWithOdfValidatorAsync(string filePath, string? jarPath, string? javaPath, int timeoutMilliseconds, CancellationToken cancellationToken)
Parameters
filePathstring要驗證的 ODF 文件路徑
jarPathstringODF Validator JAR 路徑。若未提供,會讀取
ODFKIT_ODFVALIDATOR_JARjavaPathstringJava 執行檔路徑。預設使用
javatimeoutMillisecondsint外部程序逾時毫秒數
cancellationTokenCancellationToken取消語彙基元
Returns
- Task<OdfExternalValidatorResult>
代表非同步驗證作業的工作,其結果為外部驗證器執行結果
Remarks
若 cancellationToken 已請求取消,作業會立即以 OperationCanceledException 結束;
否則會在外部子程序等待與 stdout/stderr 讀取期間協作檢查取消語彙。
Exceptions
- ArgumentException
當文件路徑或 JAR 路徑未提供時擲出
- FileNotFoundException
當文件或 JAR 不存在時擲出
- TimeoutException
當外部程序逾時時擲出