1- using WindowTranslator . Modules ;
1+ using Microsoft . Extensions . Logging ;
2+ using WindowTranslator . Modules ;
23using WindowTranslator . Plugin . OneOcrPlugin . Properties ;
34using Wpf . Ui ;
45using Wpf . Ui . Controls ;
56using Wpf . Ui . Extensions ;
67
78namespace WindowTranslator . Plugin . OneOcrPlugin ;
89
9- public class OneOcrValidator ( IContentDialogService dialogService ) : ITargetSettingsValidator
10+ public class OneOcrValidator ( IContentDialogService dialogService , ILogger < OneOcrValidator > logger ) : ITargetSettingsValidator
1011{
11- private static readonly ValidateResult Invalid = ValidateResult . Invalid ( " OneOcr" , Resources . NotFoundModule ) ;
12+ private static readonly ValidateResult Invalid = ValidateResult . Invalid ( Resources . OneOcr , Resources . NotFoundModule ) ;
1213 private readonly IContentDialogService dialogService = dialogService ;
14+ private readonly ILogger < OneOcrValidator > logger = logger ;
1315 private bool versionChecked = false ;
1416
1517 public async ValueTask < ValidateResult > Validate ( TargetSettings settings )
@@ -21,7 +23,7 @@ public async ValueTask<ValidateResult> Validate(TargetSettings settings)
2123 }
2224
2325 // ScreenSketchのバージョンをチェック
24- if ( ! this . versionChecked && ! await Utility . CheckScreenSketchVersionAsync ( ) . ConfigureAwait ( false ) )
26+ if ( ! this . versionChecked && ! await Utility . CheckScreenSketchVersionAsync ( this . logger ) )
2527 {
2628 // バージョンが古い場合、確認ダイアログを表示
2729 var confirmResult = await this . dialogService . ShowSimpleDialogAsync ( new ( )
@@ -49,9 +51,9 @@ public async ValueTask<ValidateResult> Validate(TargetSettings settings)
4951 {
5052 while ( ! checkCts . Token . IsCancellationRequested )
5153 {
52- await Task . Delay ( TimeSpan . FromSeconds ( 5 ) , checkCts . Token ) . ConfigureAwait ( false ) ;
54+ await Task . Delay ( TimeSpan . FromSeconds ( 5 ) , checkCts . Token ) ;
5355
54- if ( await Utility . CheckScreenSketchVersionAsync ( ) . ConfigureAwait ( false ) )
56+ if ( await Utility . CheckScreenSketchVersionAsync ( this . logger ) )
5557 {
5658 // 更新完了
5759 dialogCts . Cancel ( ) ;
@@ -97,10 +99,10 @@ await this.dialogService.ShowSimpleDialogAsync(new()
9799 }
98100
99101 // OneOcrのインストール先を取得
100- var oneOcrPath = await Utility . FindOneOcrPath ( ) . ConfigureAwait ( false ) ;
102+ var oneOcrPath = await Utility . FindOneOcrPath ( ) ;
101103 if ( oneOcrPath == null )
102104 {
103- return ValidateResult . Invalid ( "OneOcr" , Resources . NotFoundModule ) ;
105+ return Invalid ;
104106 }
105107
106108 // DLLをコピー
@@ -110,7 +112,7 @@ await this.dialogService.ShowSimpleDialogAsync(new()
110112 }
111113 catch ( Exception ex )
112114 {
113- return ValidateResult . Invalid ( " OneOcr" , string . Format ( Resources . CopyFaild , ex . Message ) ) ;
115+ return ValidateResult . Invalid ( Resources . OneOcr , string . Format ( Resources . CopyFaild , ex . Message ) ) ;
114116 }
115117
116118 return ValidateResult . Valid ;
0 commit comments